I'm also interested in what kind of performance improvements are happening here. Doesn't the for-loop also compute the limit of the array index only once?
On Thu, Jun 4, 2009 at 11:15 AM, Scott Blum <[email protected]> wrote: > Given that the syntax is more verbose, what kind of performance improvements > are you seeing? If this makes a measurable difference, I have to admit I'm > pretty surprised that the JVM doesn't optimize well something as common as > iterating over an array list. > On Thu, Jun 4, 2009 at 1:54 PM, <[email protected]> wrote: >> >> Reviewers: Lex, scottb, >> >> Description: >> Rewrite loops of the form: >> >> List<T> args; >> for (T arg : args) { >> } >> >> to use an explicit index. This cuts loop overhead by avoiding the need >> to instantiate an Iterator object. >> >> This speeds up a 6-permutation Showcase compile (with -soyc and -style >> PRETTY) by about 3%. >> >> >> >> Please review this at http://gwt-code-reviews.appspot.com/34829 >> >> Affected files: >> dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorder.java >> dev/core/src/com/google/gwt/dev/jjs/SourceInfoCorrelation.java >> dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java >> dev/core/src/com/google/gwt/dev/jjs/ast/JTypeOracle.java >> dev/core/src/com/google/gwt/dev/jjs/impl/CloneExpressionVisitor.java >> dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java >> dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java >> dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java >> dev/core/src/com/google/gwt/dev/js/JsInliner.java >> dev/core/src/com/google/gwt/dev/js/ast/JsVisitor.java >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
