PROPOSAL: Enhanced for each loop iteration control (original) (raw)
Stephen Colebourne scolebourne at joda.org
Mon Mar 30 16:46:04 PDT 2009
- Previous message: PROPOSAL: Enhanced for each loop iteration control
- Next message: PROPOSAL: Enhanced for each loop iteration control
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Stefan Schulz wrote:
Frankly, I cannot see a great advantage of: for (Foo foo : fooList : it) { ... } saving two lines of code over: Iterator it = fooList.iterator(); while (it.hasNext()) { Foo foo = it.next(); ... }
The former captures the intent of the loop. The latter is all about plumbing.
by adding two wrappers and stuff to the code in the background.
The proposal discusses possible optimisations, however I suspect that hohtspot can probably cope with two additional objects being created.
Remember, the extra overhead only happens if you add the optional iterator reference.
Stephen
- Previous message: PROPOSAL: Enhanced for each loop iteration control
- Next message: PROPOSAL: Enhanced for each loop iteration control
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]