Simplify dedupeStation() (#589)

13.8s locally now.

Co-authored-by: Ian Preston <ianopolous@protonmail.com>
This commit is contained in:
Dr Ian Preston 2024-01-27 18:43:41 +00:00 committed by GitHub
parent d9604d9258
commit 8279aa7560
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,12 +108,6 @@ 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;
@ -123,7 +118,6 @@ public class CalculateAverage_ianopolousfast {
stations[index] = res;
return res;
}
}
static long maskHighBytes(long d, int nbytes) {
return d & (-1L << ((8 - nbytes) * 8));