开发者

GWT optimisation

Will first line work faster than second line in GWT? Is there difference of translation this code in JavaScript in different GWT versions?

ArrayList<String> list = new ArrayList<String>(); 

List<String> list 开发者_JS百科= new ArrayList<String>(); 

As i know if i will write declearet type List, JavaScript performance will be worst, because will check is this List LinkedList or ArrayList or other type of list. Is it right?

Will it improve performance if i will write

ArrayList<String> list = new ArrayList<String>(); 

instead of

List<String> list = new ArrayList<String>(); 

?


Both lines are equivalent. The GWT compiler performs an optimization called "type tightening." You can watch how the compiler optimizes a particular method by defining a Java environment property when you compile a module:

-Dgwt.jjs.traceMethods=Hello.onModuleLoad:OtherClass.otherMethod

From the JProgram source:

The format to trace methods is a colon-separated list of "className.methodName", such as "Hello.onModuleLoad:Foo.bar". You can fully-qualify a class to disambiguate classes, and you can also append the JSNI signature of the method to disambiguate overloads, "Foo.bar(IZ)".


I'm not sure, but I think that when you use List<...> as a return type of a service method the compiler will have to compile all List implementations so it will generate larger code then if you used ArrayList


There is no difference between them, both converted to a non typed JavaScript array. After all you could also use String[], it would made no difference in the compiled code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜