Collection.toArray(new T[0]) will be faster than Collection.toArray(new T[size])
Vectorized arraycopy in the Object[] toArray() case is much faster than the type-checked arraycopy in toArray(new T[size]) and toArray(new T[0]). Alas, that does not help us if we want to get T[].
toArray(new T[0]) seems faster, safer, and contractually cleaner, and therefore should be the default choice now
Read full article from Collection.toArray(new T[0]) will be faster than Collection.toArray(new T[size])
No comments:
Post a Comment