vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.76k stars 196 forks source link

BigArrays.equals could use a more optimized loop using java.util.Arrays.equals #229

Open techsy730 opened 3 years ago

techsy730 commented 3 years ago

EDIT: Nevermind, I see you addressed this. From the Javadoc: This method uses a backward loop. It is significantly faster than the corresponding method in {@link java.util.Arrays} While we would need to benchmark whether this is still true in OpenJDK 9 and up (where they introduced the vectorized loops), I can see it still being true in the OpenJDK 8 that we are targeting.

BigArrays.equals should use java.util.Arrays.equals for all sub arrays. This would allow us to take advantage of the hotspot intrinsics OpenJDK has for those (including vectorization in later JVM releases).

Except for the KEYS_USE_REFERENCE_EQUALITY case, in which case we will still need a handwritten loop to force the == comparison.

vigna commented 3 years ago

Well, let's keep this in mind for the Java 9-only release.