uschindler commented on PR #13076:
URL: https://github.com/apache/lucene/pull/13076#issuecomment-1927790053

   I removed the integer tail and have see no difference (especially looked 
also at the non-aligned sizes):
   
   ```java
     @Override
     public int binaryHammingDistance(byte[] a, byte[] b) {
       int distance = 0, i = 0;
       for (int upperBound = a.length & ~(Long.BYTES - 1); i < upperBound; i += 
Long.BYTES) {
         distance += Long.bitCount(((long) BitUtil.VH_NATIVE_LONG.get(a, i) ^ 
(long) BitUtil.VH_NATIVE_LONG.get(b, i)) & 0xFFFFFFFFFFFFFFFFL);
       }
       // tail:
       for (; i < a.length; i++) {
         distance += Integer.bitCount((a[i] ^ b[i]) & 0xFF);
       }
       return distance;
     }
   ```
   
   I think this code is simpliest and most effective. It may not be the best 
for vector `(length % 8) == 5...7`, but I think we can live with that.


-- 
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: issues-unsubscr...@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to