Apache Lucene open-source search software
Avoid duplicate array fill in BPIndexReorderer (#12645)
gf212165d2227f838a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 0552300acae..2fdc2af5378 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -178,7 +178,7 @@ Optimizations* GITHUB#12623: Use a MergeSorter taking advantage of extra storage for StableMSBRadixSorter. (Guo Feng)-* GITHUB#12623: Write MSB VLong for better outputs sharing in block tree index, decreasing ~14% size+* GITHUB#12631: Write MSB VLong for better outputs sharing in block tree index, decreasing ~14% sizeof .tip file. (Guo Feng)Changes in runtime behaviordiff --git a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.javaindex b36ba85d086..3ed6be41317 100644--- a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java+++ b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java@@ -293,9 +293,7 @@ public final class BPIndexReorderer {int[] leftDocFreqs = state.leftDocFreqs;int[] rightDocFreqs = state.rightDocFreqs;- Arrays.fill(leftDocFreqs, 0);computeDocFreqs(left, forwardIndex, leftDocFreqs);- Arrays.fill(rightDocFreqs, 0);computeDocFreqs(right, forwardIndex, rightDocFreqs);for (int iter = 0; iter < maxIters; ++iter) {@@ -921,7 +919,7 @@ public final class BPIndexReorderer {}/** An approximate log() function in base 2 which trades accuracy for much better performance. */- static final float fastLog2(int i) {+ static float fastLog2(int i) {assert i > 0 : "Cannot compute log of i=" + i;// floorLog2 would be the exponent in the float representation of iint floorLog2 = 31 - Integer.numberOfLeadingZeros(i);