Skip to content

Commit

Permalink
Fix container inefficiencies in FieldInfos.java (#13254)
Browse files Browse the repository at this point in the history
  • Loading branch information
cinsttool authored and jpountz committed Apr 2, 2024
1 parent b984448 commit e3bad09
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.apache.lucene.index.FieldInfo.verifySameVectorOptions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -158,16 +157,15 @@ public FieldInfos(FieldInfo[] infos) {
this.softDeletesField = softDeletesField;
this.parentField = parentField;

List<FieldInfo> valuesTemp = new ArrayList<>();
List<FieldInfo> valuesTemp = new ArrayList<>(infos.length);
byNumber = new FieldInfo[size];
for (int i = 0; i < size; i++) {
byNumber[i] = byNumberTemp[i];
if (byNumberTemp[i] != null) {
valuesTemp.add(byNumberTemp[i]);
}
}
values =
Collections.unmodifiableCollection(Arrays.asList(valuesTemp.toArray(new FieldInfo[0])));
values = Collections.unmodifiableCollection(valuesTemp);
}

/**
Expand Down

0 comments on commit e3bad09

Please sign in to comment.