rymurr commented on a change in pull request #7101:
URL: https://github.com/apache/arrow/pull/7101#discussion_r422074255



##########
File path: 
java/memory/src/main/java/org/apache/arrow/memory/util/hash/SimpleHasher.java
##########
@@ -58,21 +56,21 @@ public int hashCode(long address, long length) {
     int hashValue = 0;
     int index = 0;
     while (index + 8 <= length) {
-      long longValue = getLong(address + index);
+      long longValue = MemoryUtil.UNSAFE.getLong(address + index);
       int longHash = getLongHashCode(longValue);
       hashValue = combineHashCode(hashValue, longHash);
       index += 8;
     }
 
     if (index + 4 <= length) {
-      int intValue = getInt(address + index);
+      int intValue = MemoryUtil.UNSAFE.getInt(address + index);
       int intHash = intValue;
       hashValue = combineHashCode(hashValue, intHash);
       index += 4;
     }
 
     while (index < length) {
-      byte byteValue = getByte(address + index);
+      byte byteValue = MemoryUtil.UNSAFE.getByte(address + index);

Review comment:
       A cursory look at the bytecode shows the `PlatformDependent` call 
results in a few static method invocations:
   
   `PlatformDependent.getByte` is defined as
   ``` java
   public static byte getByte(long address) {
     return PlatformDependent0.getByte(address);
   }
   ```
   and `PlatformDependent0` is
   ``` java
   public static byte getByte(long address) {
     return UNSAFE.getByte(address);
   }
   ```
   
   And the `MemoryUtil` one the same with 1 less layer of indirect static 
calls. I would anticipate the JIT would optimise the paths to be the same. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to