开发者

should I reuse gwt instances (registry objects, loaders) or obtain fresh copy every time?

开发者 https://www.devze.com 2023-04-08 22:14 出处:网络
I\'m newbie in gwt so sorry for this simple question. I can call Registry.get(\"id\") every time or 开发者_开发知识库I can cache returned value in field, what is better (how fast/slow Registry.get(\"

I'm newbie in gwt so sorry for this simple question.

I can call Registry.get("id") every time or 开发者_开发知识库I can cache returned value in field, what is better (how fast/slow Registry.get("id") is?)

Similar question for RpcProxy instance and different loader instances.


That's actually a good question. You should always try to reuse your instances instead of creating new ones, especially with GWT client Java code which becomes Javascript at runtime. The overhead of instantiating objects in JS (even with all the optimisations you get from GWT) can become quickly unwieldy if you're not carefull. Try it for yourself, have a list of 200 gwt Labels of which you only display 10 at a time versus instantiating only 10 and reusing them each time the values change, you'll see the difference in the time your browser takes to render.

0

精彩评论

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

关注公众号