Proposal: ArrayList constructor perforrmance improvement
stuart.marks at oracle.com
Tue Dec 18 22:01:30 UTC 2018
On 12/18/18 9:23 AM, Martin Buchholz wrote:
> The blessed solution to the list copy problem is probably List.copyOf
> which might do the optimization you're hoping for.
List.copyOf is fine, but note that it returns an instance of an unmodifiable
List. The main optimization it does is that if it's asked to make a copy of an
already-unmodifiable list, it simply returns its argument.
If you want an actual ArrayList instead of an unmodifiable list, of course
you'll have to use the ArrayList copy constructor or some variation.
More information about the core-libs-dev