On 6 juil, 11:07, Ed <[email protected]> wrote:
> Hellu,
>
> Should I use the foreach or for-index-loop construction?
> Is GWT smart enough to implement the best solution?
> Can I simple neglect the difference in performance ?
>
> I mean: in the Google IO presentation  they mentioned that the foreach
> construction creates a new Iterator object and as such is a bit more
> expensive. As such they used the for-index-loop construction. ... I
> can imagine when performing many foreach loops, this can become an
> issue.

Just a note to say that:
 a) there's recently been some discussion in the GWTC group about how
the GWT compiler could be made "smart enough" and not necessarily
instantiate an Iterator. The discussion then moved to more general
advanced compiler optimizations and you can see the design doc in the
wiki [1] (there's an example about that very foreach optimization at
the very end, in the "Semantic techniques" section).
 b) any way, it only affects Iterables, a foreach loop on an Array is
translated into an optimized for-index-loop (optimized == only gets
the array length once, as in the code from Jason) with zero Iterator
overhead.

[1] 
http://code.google.com/p/google-web-toolkit/wiki/AdvancedCompilerOptimizations
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to