The various fixed-arg factory methods mostly call internal varargs constructors, causing array creating and element copying. The resulting array is passed to a constructor that creates another array and copies it (or clones it) again. Consider the List.of(...) methods that call the ListN() constructor. This is quite wasteful. A likely solution is for the fixed-arg API methods to call an internal varargs method, which can trust the array because it originated internally. See Peter Levart's comments here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-May/040791.html
|