#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();
for (;;) {
switch (c) {
case 0:
if (c == 0) {
throw x.syntaxError("A JSONObject text must end with '}'");
case '}':
} else if (c == '}') {
return;
default:
} else {
key = x.nextSimpleValue(c).toString();
}

View File

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