mirror of https://github.com/apache/lucene.git
LUCENE-10403: Add ArrayUtil#grow(T[]) (#644)
This commit is contained in:
parent
ce93d45532
commit
8178ffda00
|
@ -142,6 +142,8 @@ New Features
|
|||
* LUCENE-10385: Implement Weight#count on IndexSortSortedNumericDocValuesRangeQuery
|
||||
to speed up computing the number of hits when possible. (Luca Cavanna, Adrien Grand)
|
||||
|
||||
* LUCENE-10403: Add ArrayUtil#grow(T[]). (Greg Miller)
|
||||
|
||||
Improvements
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ public final class SynonymFilter extends TokenFilter {
|
|||
|
||||
public void add(char[] output, int offset, int len, int endOffset, int posLength) {
|
||||
if (count == outputs.length) {
|
||||
outputs = ArrayUtil.grow(outputs, count + 1);
|
||||
outputs = ArrayUtil.grow(outputs);
|
||||
}
|
||||
if (count == endOffsets.length) {
|
||||
final int[] next = new int[ArrayUtil.oversize(1 + count, Integer.BYTES)];
|
||||
|
|
|
@ -223,6 +223,11 @@ public final class ArrayUtil {
|
|||
return copy;
|
||||
}
|
||||
|
||||
/** Returns a larger array, generally over-allocating exponentially */
|
||||
public static <T> T[] grow(T[] array) {
|
||||
return grow(array, 1 + array.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array whose size is at least {@code minSize}, generally over-allocating
|
||||
* exponentially
|
||||
|
|
|
@ -713,7 +713,7 @@ public class FSTCompiler<T> {
|
|||
+ " numArcs="
|
||||
+ numArcs;
|
||||
if (numArcs == arcs.length) {
|
||||
final Arc<T>[] newArcs = ArrayUtil.grow(arcs, numArcs + 1);
|
||||
final Arc<T>[] newArcs = ArrayUtil.grow(arcs);
|
||||
for (int arcIdx = numArcs; arcIdx < newArcs.length; arcIdx++) {
|
||||
newArcs[arcIdx] = new Arc<>();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue