Skip to content

Commit

Permalink
Polish "Removed some redundant 'else's using early return"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Sep 1, 2020
1 parent 2627bf8 commit f8bc656
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down
Expand Up @@ -596,10 +596,12 @@ public String optString(String name, String fallback) {
*/
public JSONArray getJSONArray(String name) throws JSONException {
Object object = get(name);
if (!(object instanceof JSONArray)) {
if (object instanceof JSONArray) {
return (JSONArray) object;
}
else {
throw JSON.typeMismatch(name, object, "JSONArray");
}
return (JSONArray) object;
}

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

/**
Expand Down
Expand Up @@ -549,13 +549,15 @@ public static int dehexchar(char hex) {
if (hex >= '0' && hex <= '9') {
return hex - '0';
}
if (hex >= 'A' && hex <= 'F') {
else if (hex >= 'A' && hex <= 'F') {
return hex - 'A' + 10;
}
if (hex >= 'a' && hex <= 'f') {
else if (hex >= 'a' && hex <= 'f') {
return hex - 'a' + 10;
}
return -1;
else {
return -1;
}
}

}

0 comments on commit f8bc656

Please sign in to comment.