Skip to content

Commit

Permalink
cleanup (#6)
Browse files Browse the repository at this point in the history
* tidy up
  • Loading branch information
bytesfellow authored Jan 28, 2024
1 parent caa5439 commit d4c889e
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/main/java/dev/morling/onebrc/CalculateAverage_bytesfellow.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void processSlice(byte[] slice) {

scheduler.execute(() -> {
List<List<LineParams>> partitionedLines = new ArrayList<>(partitionsSize());
IntStream.range(0, partitionsSize()).forEach((p) -> partitionedLines.add(new ArrayList<>(slice.length / 116 / 2))); // 116 is the max line len incl new line char
// allocate some capacity, assuming that on average lines are half of the max (407 bytes) length
IntStream.range(0, partitionsSize()).forEach((p) -> partitionedLines.add(new ArrayList<>(slice.length / 407 / 2)));

int start = 0;
int i = 0;
Expand Down Expand Up @@ -264,17 +265,6 @@ public Station(Station from) {
this.hash = from.hash;
}

private int hashCode109() {
if (len == 0)
return 0;
int h = inputSlice[startIdx];
for (int i = startIdx + 1; i < startIdx + len; i++) {
h = (h << 7) + inputSlice[i];
}
h *= 109;
return h;
}

private int hashcodeFast() {
if (len == 0) {
return 0;
Expand Down Expand Up @@ -306,13 +296,8 @@ public boolean equals(Object o) {
if (len != station.len) {
return false;
}
for (int i = 0; i < len; i++) {
if (inputSlice[startIdx + i] != station.inputSlice[station.startIdx + i]) {
return false;
}
}

return true;
return Arrays.equals(inputSlice, startIdx, startIdx + len, station.inputSlice, station.startIdx, station.startIdx + len);
}

@Override
Expand Down

0 comments on commit d4c889e

Please sign in to comment.