From 98b958a44cc337b908d344fb3c28023c12c46439 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 20 Aug 2019 21:56:42 +0200 Subject: [PATCH] Simplify the object-to-list code in GsonRuntime#toList 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. --- .../src/main/java/io/burt/jmespath/gson/GsonRuntime.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java b/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java index 9eb9a820..59cd8688 100644 --- a/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java +++ b/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java @@ -58,8 +58,9 @@ public List toList(JsonElement value) { if (value.isJsonArray()) { return new JsonArrayListWrapper(value.getAsJsonArray()); } else if (value.isJsonObject()) { - List list = new ArrayList<>(value.getAsJsonObject().size()); - for(Map.Entry entry : value.getAsJsonObject().entrySet()) { + JsonObject object = value.getAsJsonObject(); + List list = new ArrayList<>(object.size()); + for(Map.Entry entry : object.entrySet()) { list.add(entry.getValue()); } return list;