Skip to content

Commit 89210e9

Browse files
FasterXML#220 use StringBuilder instead of StringBuffer (+ some cleanup)
1 parent c72367f commit 89210e9

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

src/main/java/com/ctc/wstx/dtd/DTDId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public int hashCode() {
111111

112112
@Override
113113
public String toString() {
114-
StringBuffer sb = new StringBuffer(60);
114+
StringBuilder sb = new StringBuilder(60);
115115
sb.append("Public-id: ");
116116
sb.append(mPublicId);
117117
sb.append(", system-id: ");

src/main/java/com/ctc/wstx/evt/WstxEventReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public String getElementText() throws XMLStreamException
220220
// ??? do we need to update mPrePeekEvent now
221221

222222
String str = null;
223-
StringBuffer sb = null;
223+
StringBuilder sb = null;
224224

225225
// Ok, fine, then just need to loop through and get all the text...
226226
for (; true; evt = nextEvent()) {
@@ -240,7 +240,7 @@ public String getElementText() throws XMLStreamException
240240
str = curr;
241241
} else {
242242
if (sb == null) {
243-
sb = new StringBuffer(str.length() + curr.length());
243+
sb = new StringBuilder(str.length() + curr.length());
244244
sb.append(str);
245245
}
246246
sb.append(curr);

src/main/java/com/ctc/wstx/sr/StreamScanner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,9 @@ protected void throwNullParent(WstxInputSource curr)
11201120
* <ol>
11211121
* <li>Entity in question is a simple character entity (either one of
11221122
* 5 pre-defined ones, or using decimal/hex notation), AND
1123-
* <li>
1123+
* </li>
11241124
* <li>Entity fits completely inside current input buffer.
1125-
* <li>
1125+
* </li>
11261126
* </ol>
11271127
* If so, character value of entity is returned. Character 0 is returned
11281128
* otherwise; if so, caller needs to do full resolution.

src/test/java/org/codehaus/stax/test/stream/TestGetSegmentedText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void doTest(boolean ns, boolean coalescing, boolean autoEntity)
196196
// Sanity check #2: and string buf should have it too
197197
assertEquals
198198
("Expected segment #"+segOffset+" (one-based; read with "+readCount+" reads) to get "
199-
+expLen+" chars; StringBuffer only has "+sb.length(),
199+
+expLen+" chars; StringBuilder only has "+sb.length(),
200200
expLen, sb.length());
201201

202202
totalBuf.append(sb);

src/test/java/stax2/BaseStax2Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.codehaus.stax2.evt.*;
1515

1616
import org.codehaus.stax2.ri.Stax2ReaderAdapter;
17-
import org.codehaus.stax2.validation.ValidationProblemHandler;
18-
import org.codehaus.stax2.validation.XMLValidationException;
1917
import org.codehaus.stax2.validation.XMLValidationProblem;
2018
import org.codehaus.stax2.validation.XMLValidationSchema;
2119

src/test/java/wstxtest/io/TestUTF8Reader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package wstxtest.io;
22

33
import java.io.*;
4+
import java.util.Arrays;
45

56
import junit.framework.TestCase;
67

@@ -26,9 +27,7 @@ public void testDelAtBufferBoundary() throws IOException
2627

2728
// Create input that will cause the array index out of bounds exception
2829
byte[] inputBytes = new byte[INPUT_SIZE];
29-
for (int i=0; i < inputBytes.length; i++) {
30-
inputBytes[i] = CHAR_FILLER;
31-
}
30+
Arrays.fill(inputBytes, CHAR_FILLER);
3231
inputBytes[BYTE_BUFFER_SIZE - 1] = CHAR_DEL;
3332
InputStream in = new ByteArrayInputStream(inputBytes);
3433

0 commit comments

Comments
 (0)