#863 replace short switch statements with if-else

This commit is contained in:
Simulant 2024-03-05 22:12:57 +01:00
parent 5407423e43
commit c010033591
2 changed files with 6 additions and 10 deletions

View File

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

View File

@ -397,15 +397,14 @@ public class JSONTokener {
*/ */
public Object nextValue() throws JSONException { public Object nextValue() throws JSONException {
char c = this.nextClean(); char c = this.nextClean();
switch (c) { if (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);
} }
case '[': } else if (c == '[') {
this.back(); this.back();
try { try {
return new JSONArray(this); return new JSONArray(this);
@ -419,9 +418,7 @@ public class JSONTokener {
Object nextSimpleValue(char c) { Object nextSimpleValue(char c) {
String string; String string;
switch (c) { if (c == '"' || c == '\'') {
case '"':
case '\'':
return this.nextString(c); return this.nextString(c);
} }