Skip to content

Commit e9f3721

Browse files
FasterXML#220 fix typo: StringVector should grow by 50% when full (not 200%)
1 parent 2ba911b commit e9f3721

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/main/java/com/ctc/wstx/util/StringVector.java

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public void addString(String str) {
7676
if (mSize == mStrings.length) {
7777
String[] old = mStrings;
7878
int oldSize = old.length;
79-
mStrings = new String[oldSize + (oldSize << 1)];
79+
// grow array by 50%
80+
mStrings = new String[oldSize + (oldSize >> 1)];
8081
System.arraycopy(old, 0, mStrings, 0, oldSize);
8182
}
8283
mStrings[mSize++] = str;
@@ -86,7 +87,8 @@ public void addStrings(String str1, String str2) {
8687
if ((mSize + 2) > mStrings.length) {
8788
String[] old = mStrings;
8889
int oldSize = old.length;
89-
mStrings = new String[oldSize + (oldSize << 1)];
90+
// grow array by 50%
91+
mStrings = new String[oldSize + (oldSize >> 1)];
9092
System.arraycopy(old, 0, mStrings, 0, oldSize);
9193
}
9294
mStrings[mSize] = str1;
@@ -187,35 +189,6 @@ public int findLastIndexByValueNonInterned(String value) {
187189
return -1;
188190
}
189191

190-
/*
191-
// Not needed any more
192-
public Iterator findAllByValueNonInterned(String value) {
193-
String first = null;
194-
ArrayList all = null;
195-
for (int index = mSize-1; index > 0; index -= 2) {
196-
String currVal = mStrings[index];
197-
if (currVal == value || (currVal != null && currVal.equals(value))) {
198-
if (first == null) {
199-
first = mStrings[index-1];
200-
} else {
201-
if (all == null) {
202-
all = new ArrayList();
203-
all.add(first);
204-
}
205-
all.add(mStrings[index-1]);
206-
}
207-
}
208-
}
209-
if (all != null) {
210-
return all.iterator();
211-
}
212-
if (first != null) {
213-
return new SingletonIterator(first);
214-
}
215-
return DataUtil.emptyIterator();
216-
}
217-
*/
218-
219192
/*
220193
///////////////////////////////////////////////////////
221194
// Other methods

0 commit comments

Comments
 (0)