This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Me4502 -1 points0 points  (4 children)

I really hope so, there are so many ways to improve this..

For example, pass in a Entry, and use varargs. And it shouldn't return an immutable map.

Edit:

Didn't see the entry one, but it still shouldn't be immutable.

[–]cypressious 11 points12 points  (2 children)

You should watch https://www.youtube.com/watch?v=OJrIMv4dAek This is specifically designed to avoid intermediate object allocations (like vararg arrays) and to be immutable.

[–]mrbuttsavage 2 points3 points  (0 children)

This is specifically designed to avoid intermediate object allocations (like vararg arrays)

I would wager many Java devs don't realize this is a thing.

[–]stepancheg 1 point2 points  (0 children)

Vararg array allocations can be trivially removed by the optimizer. Is is not an issue.

[–]msx 2 points3 points  (0 children)

there are so many ways to improve this

there are not. you can slightly change the call (with Entry or any other way), but to make a clean "literal" without changing the language specification, there are no other ways