Skip to content

Commit 7b9d7f2

Browse files
author
Bytekeeper
committed
Fixed a small bug and tuned a "parameter" for better performance
1 parent 26ecb28 commit 7b9d7f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/bk/ass/query/PositionQueries.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private Pivot partitionX(int start, int end) {
261261
if (pos(mid).x < pos(end).x) swap(mid, end);
262262
int pivot = pos(end).x;
263263
while (true) {
264-
while (pos(start).x < pivot) start++;
264+
while (pos(start).x <= pivot) start++;
265265
while (pos(end).x > pivot) end--;
266266
if (start >= end) return new Pivot(pivot, end);
267267
swap(start, end);
@@ -293,7 +293,8 @@ private void swap(int a, int b) {
293293
}
294294

295295
private Node makeTree(int start, int end, boolean xDim) {
296-
if (end - start < 10) return new Node(Arrays.copyOfRange(data, start, end + 1));
296+
// 15 elements seems to be the sweet spot for ~1000 positions
297+
if (end - start < 15) return new Node(Arrays.copyOfRange(data, start, end + 1));
297298
Pivot pivot;
298299
if (xDim) {
299300
pivot = partitionX(start, end);

0 commit comments

Comments
 (0)