diff --git a/src/main/java/dev/morling/onebrc/CalculateAverage_ianopolousfast.java b/src/main/java/dev/morling/onebrc/CalculateAverage_ianopolousfast.java index ab960df..28f62a4 100644 --- a/src/main/java/dev/morling/onebrc/CalculateAverage_ianopolousfast.java +++ b/src/main/java/dev/morling/onebrc/CalculateAverage_ianopolousfast.java @@ -19,6 +19,7 @@ import jdk.incubator.vector.ByteVector; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.VectorSpecies; +import java.io.IOException; import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; import java.nio.ByteOrder; @@ -41,7 +42,7 @@ import static java.lang.foreign.ValueLayout.*; * * Timings on 4 core i7-7500U CPU @ 2.70GHz: * average_baseline: 4m48s - * ianopolous: 14s + * ianopolous: 13.8s */ public class CalculateAverage_ianopolousfast { @@ -107,22 +108,15 @@ public class CalculateAverage_ianopolousfast { public static Stat dedupeStation(long start, long end, long hash, MemorySegment buffer, Stat[] stations) { int index = hashToIndex(hash, MAX_STATIONS); Stat match = stations[index]; - if (match == null) { - Stat res = createStation(start, end, buffer); - stations[index] = res; - return res; - } - else { - while (match != null) { - if (matchingStationBytes(start, end, buffer, match)) - return match; - index = (index + 1) % stations.length; - match = stations[index]; - } - Stat res = createStation(start, end, buffer); - stations[index] = res; - return res; + while (match != null) { + if (matchingStationBytes(start, end, buffer, match)) + return match; + index = (index + 1) % stations.length; + match = stations[index]; } + Stat res = createStation(start, end, buffer); + stations[index] = res; + return res; } static long maskHighBytes(long d, int nbytes) {