lucene
lucene copied to clipboard
Reduce some unnecessary ArrayUtil#grow calls
This change will slightly improve the performance of DataOutput#writeGroupVInts and some other methods related to XXXRefBuilder#append.
Here is a JMH benchmark for Util.toIntsRef, using java 21 on my MAC (intel chip).
Benchmark Mode Cnt Score Error Units
PR ToIntsRefBenchMark.run thrpt 5 38.208 ± 1.054 ops/us
main ToIntsRefBenchMark.run thrpt 5 7.862 ± 0.832 ops/us
JMH benchmark code for Util#toIntsRef:
public class ToIntsRefBenchMark {
IntsRefBuilder intsRefBuilder = new IntsRefBuilder();
BytesRef bytesRef = new BytesRef(new byte[32]);
@Benchmark
public void run() {
Util.toIntsRef(bytesRef, intsRefBuilder);
}
}