Simplify dedupeStation() (#589)
13.8s locally now. Co-authored-by: Ian Preston <ianopolous@protonmail.com>
This commit is contained in:
parent
d9604d9258
commit
8279aa7560
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user