diff options
| author | Dr Ian Preston <157221403+ianopolousfast@users.noreply.github.com> | 2024-01-27 18:43:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-27 19:43:41 +0100 |
| commit | 8279aa7560833ef61653a175a8864fc985b5defb (patch) | |
| tree | 5f693d2e4c09bb8f1c70e455e209f5d836590d06 /src | |
| parent | d9604d9258ce29d955d89ce3f6d72dfd5119a42a (diff) | |
Simplify dedupeStation() (#589)
13.8s locally now.
Co-authored-by: Ian Preston <ianopolous@protonmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/dev/morling/onebrc/CalculateAverage_ianopolousfast.java | 26 |
1 files changed, 10 insertions, 16 deletions
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) { |
