mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 03:06:03 +08:00
Revert "#863 improve performance of JSONTokener#nextString"
This reverts commit 63625b3c62
.
This commit is contained in:
@@ -295,9 +295,12 @@ public class JSONTokener {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = this.next();
|
c = this.next();
|
||||||
if (c == quote) {
|
switch (c) {
|
||||||
return sb.toString();
|
case 0:
|
||||||
} else if (c == '\\') {
|
case '\n':
|
||||||
|
case '\r':
|
||||||
|
throw this.syntaxError("Unterminated string");
|
||||||
|
case '\\':
|
||||||
c = this.next();
|
c = this.next();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -331,9 +334,11 @@ public class JSONTokener {
|
|||||||
default:
|
default:
|
||||||
throw this.syntaxError("Illegal escape.");
|
throw this.syntaxError("Illegal escape.");
|
||||||
}
|
}
|
||||||
} else if (c == 0 || c == '\n' || c == '\r') {
|
break;
|
||||||
throw this.syntaxError("Unterminated string");
|
default:
|
||||||
} else {
|
if (c == quote) {
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user