It is a known fact, that in Java it is good practice to return Collections.emptyList instead of empty ArrayList object. When writing for GWT, how does GWT compiler treat this emptyList – is it as efficient to use as ArrayList or it doesn’t make any sense?
Share
Collections.emptyList()might be better thannew ArrayList()(compare this to that), but I believe it actually doesn’t matter (ArrayListis probably used anyway –it’s used internally in widgets–, so it won’t be optimized out if you useCollections.emptyList(), and theEmptyListis so small that it’s not worth optimizing it out; and again it might also be used somewhere by code you didn’t write, so…).As a rule of thumb, you shouldn’t care for micro-optimizations unless you have a performance/code-size issue that needs fixing. “Premature optimization is the root of all evil.” (Donald Knuth)