lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toke Eskildsen ...@statsbiblioteket.dk>
Subject Re: [jira] Created: (LUCENE-1257) Port to Java5
Date Fri, 04 Apr 2008 08:40:16 GMT
On Wed, 2008-04-02 at 09:30 -0400, Mark Miller wrote:
> > - replacement of indexed for loops with for each constructs
> 
> Is this always the best idea? Doesn't the for loop construct make an
> iterator, which can be much slower than an indexed for loop?

Only in the case of iterations over collections. For arrays, the foreach
is syntactic sugar for indexed for-loop.
http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.14.2

Whether or not using an iterator for e.g. ArrayList is better than an
indexed for-loop is another question. This is the old problems of
balancing general code vs. performance: An indexed for-loop might be
faster than an iterator for ArrayList, but it is definitely slower for
LinkedList.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message