Revert "#863 improve performance of JSONTokener#nextString"

This reverts commit 63625b3c622407273d2654660be7659ac5d74db7.
This commit is contained in:
Simulant 2024-03-10 21:12:28 +01:00
parent 5974fc1a38
commit 0c5cf18255

View File

@ -295,9 +295,12 @@ public class JSONTokener {
StringBuilder sb = new StringBuilder();
for (;;) {
c = this.next();
if (c == quote) {
return sb.toString();
} else if (c == '\\') {
switch (c) {
case 0:
case '\n':
case '\r':
throw this.syntaxError("Unterminated string");
case '\\':
c = this.next();
switch (c) {
case 'b':
@ -331,9 +334,11 @@ public class JSONTokener {
default:
throw this.syntaxError("Illegal escape.");
}
} else if (c == 0 || c == '\n' || c == '\r') {
throw this.syntaxError("Unterminated string");
} else {
break;
default:
if (c == quote) {
return sb.toString();
}
sb.append(c);
}
}