Skip to content

Commit 29dd02d

Browse files
authored
Merge pull request #37 from jochenberger/patch-1
Avoid costly call to String#trim()
2 parents 8669ad9 + f32e2ff commit 29dd02d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

json-smart/src/main/java/net/minidev/json/parser/JSONParserString.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ protected void extractString(int beginIndex, int endIndex) {
6363
}
6464

6565
protected void extractStringTrim(int start, int stop) {
66+
while (start < stop-1 && Character.isWhitespace(in.charAt(start))) {
67+
start++;
68+
}
69+
while (stop-1 > start && Character.isWhitespace(in.charAt(stop-1))) {
70+
stop--;
71+
}
6672
extractString(start, stop);
67-
xs = xs.trim();
6873
}
6974

7075
protected int indexOf(char c, int pos) {

0 commit comments

Comments
 (0)