optimize branches (#534)
This commit is contained in:
parent
47269cf30b
commit
6b95ac6113
@ -140,6 +140,7 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
|
|
||||||
private static final int ENTRIES = 64 * 1024;
|
private static final int ENTRIES = 64 * 1024;
|
||||||
private static final int SIZE = 128 * ENTRIES;
|
private static final int SIZE = 128 * ENTRIES;
|
||||||
|
private static final int MASK = (ENTRIES - 1) << 7;
|
||||||
|
|
||||||
private final ByteBuffer buffer = allocate(SIZE);
|
private final ByteBuffer buffer = allocate(SIZE);
|
||||||
private final long pointer = address(buffer);
|
private final long pointer = address(buffer);
|
||||||
@ -261,7 +262,7 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int offset(int hash) {
|
private static int offset(int hash) {
|
||||||
return ((hash) & (ENTRIES - 1)) << 7;
|
return hash & MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int next(int prev) {
|
private static int next(int prev) {
|
||||||
@ -361,7 +362,6 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
int length;
|
int length;
|
||||||
int hash;
|
int hash;
|
||||||
|
|
||||||
long ptr = 0;
|
|
||||||
long word = word(position);
|
long word = word(position);
|
||||||
long separator = separator(word);
|
long separator = separator(word);
|
||||||
|
|
||||||
@ -369,7 +369,12 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
length = length(separator);
|
length = length(separator);
|
||||||
word = mask(word, separator);
|
word = mask(word, separator);
|
||||||
hash = mix(word);
|
hash = mix(word);
|
||||||
ptr = aggregates.find(word, hash);
|
long ptr = aggregates.find(word, hash);
|
||||||
|
|
||||||
|
if (ptr != 0) {
|
||||||
|
position = update(ptr, position + length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
long word0 = word;
|
long word0 = word;
|
||||||
@ -380,7 +385,12 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
length = length(separator) + 8;
|
length = length(separator) + 8;
|
||||||
word = mask(word, separator);
|
word = mask(word, separator);
|
||||||
hash = mix(word ^ word0);
|
hash = mix(word ^ word0);
|
||||||
ptr = aggregates.find(word0, word, hash);
|
long ptr = aggregates.find(word0, word, hash);
|
||||||
|
|
||||||
|
if (ptr != 0) {
|
||||||
|
position = update(ptr, position + length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
length = 16;
|
length = 16;
|
||||||
@ -404,10 +414,7 @@ public class CalculateAverage_artsiomkorzun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr == 0) {
|
long ptr = aggregates.put(position, word, length, hash);
|
||||||
ptr = aggregates.put(position, word, length, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
position = update(ptr, position + length);
|
position = update(ptr, position + length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user