Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4e5061f authored by Mathieu Chartier's avatar Mathieu Chartier
Browse files

Change EmptyArray System.identityHashCode to Object.hashCode.

Equivalent behavior, improves performance since
Object.hashCode has a fast path in the java side that does not
require JNI.

According to traceview sampling profiler:
Calendar had 6.8% time in System.identityHashCode during launch.
0.4% time in System.identityHashCode after the change.

Bug: 16828525

Change-Id: I1ed1d1283a990f990b0d4352cc1f4822b1dadf7b
parent 6cb95276
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class ArrayUtils
            return (T[]) EmptyArray.OBJECT;
        }

        int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE;
        int bucket = (kind.hashCode() & 0x7FFFFFFF) % CACHE_SIZE;
        Object cache = sCache[bucket];

        if (cache == null || cache.getClass().getComponentType() != kind) {