On 4/4/19 3:29 AM, Claes Redestad wrote:
a few of the ImmutableCollections are inheriting size and/or isEmpty
from abstract base classes. A few of these are inefficiently
implemented, e.g., on a Map1, isEmpty() will effectively be
"return entrySet().size() == 0" when it could be simply "return
false".

Ugh!

This patch provide specialized implementations which JITs do the right
thing while also helping startup slightly.

Bug:    https://bugs.openjdk.java.net/browse/JDK-8221921
Webrev: http://cr.openjdk.java.net/~redestad/8221921/open.00/

Testing: tier1-2, verified a tiny improvement in startup profiles

[this is from ListN]

@@ -483,11 +488,11 @@
             elements = tmp;
         }
@Override
         public boolean isEmpty() {
-            return size() == 0;
+            return elements.length == 0;
         }
@Override
         public int size() {
             return elements.length;

You're really splitting bytecodes aren't you? :-)

Anyway, changeset looks good.

s'marks

Reply via email to