From e3bad09e2c09d1c60c9930b2e89e0814714f55da Mon Sep 17 00:00:00 2001 From: cinsttool <165570940+cinsttool@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:12:17 +0800 Subject: [PATCH] Fix container inefficiencies in FieldInfos.java (#13254) --- .../core/src/java/org/apache/lucene/index/FieldInfos.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java index 56ea002db476..f0fbb09cf000 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java @@ -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; @@ -158,7 +157,7 @@ public FieldInfos(FieldInfo[] infos) { this.softDeletesField = softDeletesField; this.parentField = parentField; - List valuesTemp = new ArrayList<>(); + List valuesTemp = new ArrayList<>(infos.length); byNumber = new FieldInfo[size]; for (int i = 0; i < size; i++) { byNumber[i] = byNumberTemp[i]; @@ -166,8 +165,7 @@ public FieldInfos(FieldInfo[] infos) { valuesTemp.add(byNumberTemp[i]); } } - values = - Collections.unmodifiableCollection(Arrays.asList(valuesTemp.toArray(new FieldInfo[0]))); + values = Collections.unmodifiableCollection(valuesTemp); } /**