From lucene-dev-return-2749-qmlist-jakarta-archive-lucene-dev=jakarta.apache.org@jakarta.apache.org Tue Nov 26 10:49:37 2002
Return-Path:
Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org
Received: (qmail 74457 invoked from network); 26 Nov 2002 10:49:36 -0000
Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131)
by daedalus.apache.org with SMTP; 26 Nov 2002 10:49:36 -0000
Received: (qmail 11616 invoked by uid 97); 26 Nov 2002 10:50:49 -0000
Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org
Received: (qmail 11564 invoked by uid 97); 26 Nov 2002 10:50:48 -0000
Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe:
List-Subscribe:
List-Help:
List-Post:
List-Id: "Lucene Developers List"
Reply-To: "Lucene Developers List"
Delivered-To: mailing list lucene-dev@jakarta.apache.org
Received: (qmail 11540 invoked by uid 98); 26 Nov 2002 10:50:46 -0000
X-Antivirus: nagoya (v4218 created Aug 14 2002)
Message-ID: <00dc01c29585$65fe7880$660010ac@teck>
From: "Julien Nioche"
To: "Lucene Developers List"
References: <20021121184830.5870.qmail@web12707.mail.yahoo.com>
Subject: computing size() in frequently used methods
Date: Tue, 26 Nov 2002 11:52:45 -0800
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
Hello,
In the code of BooleanQuery and PhraseQuery loops are made using a size()
method to check the bound. Since the methods of these classes are used very
often, it could be useful to change the code in order to compute the size of
the object only once, store it in an integer and check the bound on that
integer.
For example, the method sumOfSquaredWeights of the class BooleanQuery
currently use the following :
for (int i = 0 ; i < clauses.size(); i++) {
...
}
which could be replaced by :
int clausenumber = clauses.size();
for (int i = 0 ; i < clausenumber; i++)
{...}
This kind of modification could be done in almost all the methods of the
classes BooleanQuery and PhraseQuery, providing a small optimization (I did
not mesure it - but even small optimizations can be useful).
Supposing that the size of the clauses or terms Vectors is not likely to
change during the execution of these methods, this kind of change must be
pretty harmless...
Any opinion on that? Could it have a side effect?
Julien Nioche
www.lingway.com
--
To unsubscribe, e-mail:
For additional commands, e-mail: