I tend to use (or even overuse) double braces object intialization in GWT. For me it looks more readable and more declarative.
new FastMap<Object>(){{
put("Value", 12);
put("Unit", "Kg");
}};
Before today I was not aware that this syntax is not just instantiate object but also create AnonymousInnerClass for it. Now I am concerned how GWT deal with them.
- How this syntax affects perfomance of the execution?
- How this syntax affects compiled size?
- Any other bad thing?
I have thousands of such initializations in my app.
My findings. Test code. I am creating single list with 4 maps with 21 item each. I am measuring size of all generated JavaScript files. Results:
Empty (just empty code to make sure that GWT support code rendered):
new= 167Code without double braces:
new= 171And same code with double braces:
new= 177I think results are pretty self-explanatory.