GWT: How to avoiding calls to dynamicCast and canCastUnsafe in generated JavaScript code?

后端 未结 5 822
醉梦人生
醉梦人生 2021-01-12 12:32

I\'m writing some special purpose data structures in Java, intended for use in the browser, (compiled to JavaScript with GWT).

I\'m trying to match the performance o

5条回答
  •  半阙折子戏
    2021-01-12 13:15

    An updated answer for GWT version 2.1 and later:

    Since GWT 2.1 (at least that's the first mention), the GWT compiler has a new compiler argument called -XdisableCastChecking that disables all runtime checking of casts. Note, this option is marked as experimental (probably because this would make class cast exceptions very hard to debug).

    In my app dynamicCast was called thousands of times in a short profile run, and were the the 3rd most time consuming method in the Firebug profiler. Using this compiler argument significantly reduced the number of "Long Duration Events" messages in the Chrome Speed Tracer.

    See GWT Compiler Options for this and other Compiler arguments.

提交回复
热议问题