Polish "Removed some redundant 'else's using early return"

See gh-22528
pull/23161/head
Stephane Nicoll 4 years ago
parent 2627bf896e
commit f8bc656921

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -596,10 +596,12 @@ public class JSONObject {
*/ */
public JSONArray getJSONArray(String name) throws JSONException { public JSONArray getJSONArray(String name) throws JSONException {
Object object = get(name); Object object = get(name);
if (!(object instanceof JSONArray)) { if (object instanceof JSONArray) {
return (JSONArray) object;
}
else {
throw JSON.typeMismatch(name, object, "JSONArray"); throw JSON.typeMismatch(name, object, "JSONArray");
} }
return (JSONArray) object;
} }
/** /**
@ -623,10 +625,12 @@ public class JSONObject {
*/ */
public JSONObject getJSONObject(String name) throws JSONException { public JSONObject getJSONObject(String name) throws JSONException {
Object object = get(name); Object object = get(name);
if (!(object instanceof JSONObject)) { if (object instanceof JSONObject) {
return (JSONObject) object;
}
else {
throw JSON.typeMismatch(name, object, "JSONObject"); throw JSON.typeMismatch(name, object, "JSONObject");
} }
return (JSONObject) object;
} }
/** /**

@ -549,13 +549,15 @@ public class JSONTokener {
if (hex >= '0' && hex <= '9') { if (hex >= '0' && hex <= '9') {
return hex - '0'; return hex - '0';
} }
if (hex >= 'A' && hex <= 'F') { else if (hex >= 'A' && hex <= 'F') {
return hex - 'A' + 10; return hex - 'A' + 10;
} }
if (hex >= 'a' && hex <= 'f') { else if (hex >= 'a' && hex <= 'f') {
return hex - 'a' + 10; return hex - 'a' + 10;
} }
else {
return -1; return -1;
} }
}
} }

Loading…
Cancel
Save