-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
-
generic
-
generic
I noticed that the implementations of the lists returned by java.util.Collections emptyList, singletonList, and nCopies methods lack reversed() implementation, and instead rely on the default implementation, which creates a ReverseOrderListView wrapper. However, for these three lists, the reversed view is completely equivalent to the original list, so returning `this` from reversed() would be more optimal.
Another thing that could be specialized is getFirst() and getLast() implementations of singletonList. They can simply return an element without extra checks. While extra checks could be eliminated by advanced JIT compiler with sufficient inlining, this specialization still might be helpful if inlining fails (e.g., due to polymorphic call site).
Another thing that could be specialized is getFirst() and getLast() implementations of singletonList. They can simply return an element without extra checks. While extra checks could be eliminated by advanced JIT compiler with sufficient inlining, this specialization still might be helpful if inlining fails (e.g., due to polymorphic call site).
- links to
-
Review(master) openjdk/jdk/27406