-
Enhancement
-
Resolution: Duplicate
-
P3
-
None
-
8
-
windows_8
A DESCRIPTION OF THE REQUEST :
The j.u.Collections.sort() methods always iterate over the array returned by list.toArray(). It would be nicer to check, whether the array has at least 2 elements.
JUSTIFICATION :
Insert the line
if (list.size() < 2) return;
as the first line of both j.u.Collections.sort() methods or
if (a.length < 2) return;
after the toArray() call.
The j.u.Collections.sort() methods always iterate over the array returned by list.toArray(). It would be nicer to check, whether the array has at least 2 elements.
JUSTIFICATION :
Insert the line
if (list.size() < 2) return;
as the first line of both j.u.Collections.sort() methods or
if (a.length < 2) return;
after the toArray() call.
- duplicates
-
JDK-8015708 Collections.sort creates a temporary array even for elements of size 1
-
- Open
-