LUCENE-7205: Remove repeated nl.getLength() calls in (Boolean|DisjunctionMax|FuzzyLikeThis)QueryBuilder.

This commit is contained in:
Christine Poerschke 2016-04-13 11:27:17 +01:00
parent ca83f60438
commit 87d7de0d98
4 changed files with 9 additions and 3 deletions

View File

@ -77,6 +77,9 @@ Other
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
* LUCENE-7205: Remove repeated nl.getLength() calls in
(Boolean|DisjunctionMax|FuzzyLikeThis)QueryBuilder. (Christine Poerschke)
======================= Lucene 6.0.0 =======================
System Requirements

View File

@ -49,7 +49,8 @@ public class BooleanQueryBuilder implements QueryBuilder {
bq.setMinimumNumberShouldMatch(DOMUtils.getAttribute(e, "minimumNumberShouldMatch", 0));
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
final int nlLen = nl.getLength();
for (int i = 0; i < nlLen; i++) {
Node node = nl.item(i);
if (node.getNodeName().equals("Clause")) {
Element clauseElem = (Element) node;

View File

@ -49,7 +49,8 @@ public class DisjunctionMaxQueryBuilder implements QueryBuilder {
List<Query> disjuncts = new ArrayList<>();
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
final int nlLen = nl.getLength();
for (int i = 0; i < nlLen; i++) {
Node node = nl.item(i);
if (node instanceof Element) { // all elements are disjuncts.
Element queryElem = (Element) node;

View File

@ -50,7 +50,8 @@ public class FuzzyLikeThisQueryBuilder implements QueryBuilder {
FuzzyLikeThisQuery fbq = new FuzzyLikeThisQuery(maxNumTerms, analyzer);
fbq.setIgnoreTF(DOMUtils.getAttribute(e, "ignoreTF", DEFAULT_IGNORE_TF));
for (int i = 0; i < nl.getLength(); i++) {
final int nlLen = nl.getLength();
for (int i = 0; i < nlLen; i++) {
Element fieldElem = (Element) nl.item(i);
float minSimilarity = DOMUtils.getAttribute(fieldElem, "minSimilarity", DEFAULT_MIN_SIMILARITY);
int prefixLength = DOMUtils.getAttribute(fieldElem, "prefixLength", DEFAULT_PREFIX_LENGTH);