diff --git a/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java index 087a8e1d2f..586ba1613c 100644 --- a/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java +++ b/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java @@ -64,16 +64,21 @@ public void timeBagOfPrimitivesStreaming(int reps) throws IOException { String stringValue = null; while (jr.hasNext()) { String name = jr.nextName(); - if (name.equals("longValue")) { - longValue = jr.nextLong(); - } else if (name.equals("intValue")) { - intValue = jr.nextInt(); - } else if (name.equals("booleanValue")) { - booleanValue = jr.nextBoolean(); - } else if (name.equals("stringValue")) { - stringValue = jr.nextString(); - } else { - throw new IOException("Unexpected name: " + name); + switch (name) { + case "longValue": + longValue = jr.nextLong(); + break; + case "intValue": + intValue = jr.nextInt(); + break; + case "booleanValue": + booleanValue = jr.nextBoolean(); + break; + case "stringValue": + stringValue = jr.nextString(); + break; + default: + throw new IOException("Unexpected name: " + name); } } jr.endObject(); diff --git a/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java index e38263e33b..f9a89bc4e5 100644 --- a/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java +++ b/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java @@ -76,16 +76,21 @@ public void timeCollectionsStreaming(int reps) throws IOException { String stringValue = null; while (jr.hasNext()) { String name = jr.nextName(); - if (name.equals("longValue")) { - longValue = jr.nextLong(); - } else if (name.equals("intValue")) { - intValue = jr.nextInt(); - } else if (name.equals("booleanValue")) { - booleanValue = jr.nextBoolean(); - } else if (name.equals("stringValue")) { - stringValue = jr.nextString(); - } else { - throw new IOException("Unexpected name: " + name); + switch (name) { + case "longValue": + longValue = jr.nextLong(); + break; + case "intValue": + intValue = jr.nextInt(); + break; + case "booleanValue": + booleanValue = jr.nextBoolean(); + break; + case "stringValue": + stringValue = jr.nextString(); + break; + default: + throw new IOException("Unexpected name: " + name); } } jr.endObject();