Revert "#863 replace short switch statements with if-else"

This reverts commit c010033591c192a0821bdd8fe23bc61cdc6fe738.
This commit is contained in:
Simulant 2024-03-10 21:08:10 +01:00
parent eda08415ca
commit 045324ab42
2 changed files with 10 additions and 6 deletions

View File

@ -216,11 +216,12 @@ public class JSONObject {
} }
c = x.nextClean(); c = x.nextClean();
for (;;) { for (;;) {
if (c == 0) { switch (c) {
case 0:
throw x.syntaxError("A JSONObject text must end with '}'"); throw x.syntaxError("A JSONObject text must end with '}'");
} else if (c == '}') { case '}':
return; return;
} else { default:
key = x.nextSimpleValue(c).toString(); key = x.nextSimpleValue(c).toString();
} }

View File

@ -397,14 +397,15 @@ public class JSONTokener {
*/ */
public Object nextValue() throws JSONException { public Object nextValue() throws JSONException {
char c = this.nextClean(); char c = this.nextClean();
if (c == '{') { switch (c) {
case '{':
this.back(); this.back();
try { try {
return new JSONObject(this); return new JSONObject(this);
} catch (StackOverflowError e) { } catch (StackOverflowError e) {
throw new JSONException("JSON Array or Object depth too large to process.", e); throw new JSONException("JSON Array or Object depth too large to process.", e);
} }
} else if (c == '[') { case '[':
this.back(); this.back();
try { try {
return new JSONArray(this); return new JSONArray(this);
@ -418,7 +419,9 @@ public class JSONTokener {
Object nextSimpleValue(char c) { Object nextSimpleValue(char c) {
String string; String string;
if (c == '"' || c == '\'') { switch (c) {
case '"':
case '\'':
return this.nextString(c); return this.nextString(c);
} }