From 393065d27bcea69374693888f9f5902d672ec11e Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Tue, 6 Oct 2015 12:43:57 +0000 Subject: [PATCH] LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList in MultiFieldQueryNodeProcessor git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1707040 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../MultiFieldQueryNodeProcessor.java | 17 ++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index f2c748577b6..77315b9f66f 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -172,6 +172,9 @@ Bug Fixes Other +* 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.java index 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 children = new LinkedList<>(); - children.add(fieldNode); + List 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 { @Override protected List setChildrenOrder(List children) throws QueryNodeException { - return children; - } - }