ulysses-you commented on a change in pull request #14762:
URL: https://github.com/apache/spark/pull/14762#discussion_r776911919



##########
File path: 
common/unsafe/src/main/java/org/apache/spark/unsafe/array/ByteArrayMethods.java
##########
@@ -40,24 +40,41 @@ public static int roundNumberOfBytesToNearestWord(int 
numBytes) {
     }
   }
 
+  private static final boolean unaligned = Platform.unaligned();
   /**
    * Optimized byte array equality check for byte arrays.
    * @return true if the arrays are equal, false otherwise
    */
   public static boolean arrayEquals(
       Object leftBase, long leftOffset, Object rightBase, long rightOffset, 
final long length) {
     int i = 0;
-    while (i <= length - 8) {
-      if (Platform.getLong(leftBase, leftOffset + i) !=
-        Platform.getLong(rightBase, rightOffset + i)) {
-        return false;
+
+    // check if stars align and we can get both offsets to be aligned
+    if ((leftOffset % 8) == (rightOffset % 8)) {

Review comment:
       @srowen sorry for the so late comment, shall we add `!unaligned` here to 
fast-fail the condition ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to