Apache Lucene open-source search software
LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList in MultiFieldQueryNodeProcessor
Dawid Weiss393065d27bce
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex f2c748577b6..77315b9f66f 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -172,6 +172,9 @@ Bug FixesOther+* LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList+ in MultiFieldQueryNodeProcessor. (Dawid Weiss).+* LUCENE-6812: Upgrade RandomizedTesting to 2.1.17. (Dawid Weiss)* LUCENE-6174: Improve "ant eclipse" to select right JRE for building.diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.javaindex 20708a4b958..c4e5ed72598 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java@@ -17,6 +17,7 @@ package org.apache.lucene.queryparser.flexible.standard.processors;* limitations under the License.*/+import java.util.ArrayList;import java.util.LinkedList;import java.util.List;@@ -91,32 +92,25 @@ public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl {if (fields.length == 1) {return fieldNode;-} else {- LinkedList<QueryNode> children = new LinkedList<>();- children.add(fieldNode);+ List<QueryNode> children = new ArrayList<>(fields.length);+ children.add(fieldNode);for (int i = 1; i < fields.length; i++) {try {fieldNode = (FieldableNode) fieldNode.cloneTree();fieldNode.setField(fields[i]);children.add(fieldNode);-} catch (CloneNotSupportedException e) {- // should never happen+ throw new RuntimeException(e);}-}return new GroupQueryNode(new OrQueryNode(children));-}-}-}-}return node;@@ -126,9 +120,6 @@ public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl {@Overrideprotected List<QueryNode> setChildrenOrder(List<QueryNode> children)throws QueryNodeException {-return children;-}-}