Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Simplify the object-to-list code in GsonRuntime#toList
Browse files Browse the repository at this point in the history
It looks unnecessary to call #getAsJsonArray twice. It's probably just a `return this`, so not calling it is probably not really any performance improvement, but it makes the code easier to read.
  • Loading branch information
iconara committed Aug 23, 2019
1 parent 9edf6ca commit 98b958a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public List<JsonElement> toList(JsonElement value) {
if (value.isJsonArray()) {
return new JsonArrayListWrapper(value.getAsJsonArray());
} else if (value.isJsonObject()) {
List<JsonElement> list = new ArrayList<>(value.getAsJsonObject().size());
for(Map.Entry<String, JsonElement> entry : value.getAsJsonObject().entrySet()) {
JsonObject object = value.getAsJsonObject();
List<JsonElement> list = new ArrayList<>(object.size());
for(Map.Entry<String, JsonElement> entry : object.entrySet()) {
list.add(entry.getValue());
}
return list;
Expand Down

0 comments on commit 98b958a

Please sign in to comment.