Modulo ClassCastException and the like (e.g. instanceof checks), Java arrays 
are compiles straight into JavaScript arrays; while collections have an 
emulated "wrapper" class around a JavaScript array.
However, due to how the compiler inlines methods, most accesses to a 
collection's item (i.e. by index) only involve a single additional step 
cmpared to using Java arrays: dereferencing the property ofthe collection 
object containing the JS array (this is assuming a java.util.List, of course 
things are different with java.util.Set, for instance). Where things ge more 
different is for "for (... : ...)" loops, which are translated into "for 
(int i=0,l=array.length; i< l; i++)" loops for arrays, but use an emulated 
java.util.Iterator for collections.

That being said, given the speed of today's JS engines it should not make a 
difference (maybe on IE6 ? on mobiles ?)

I'd personnally stick with collections if they better fit your use case 
(variable length, inserting/removing values, etc.) as your code will be more 
readable and thus more maintainable. And only if performance is an issue 
then investigate, but there will probably be other bottlenecks than arrays 
vs. collections! (widgets, DOM manipulations, network, including building 
and parsing request/response payload, etc.)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to