[PATCH] Optimized murmurhash performance

Matthew Marangoni matthew.marangoni at gmail.com
Fri Feb 2 19:10:57 UTC 2018


# HG changeset patch
# User Matthew Marangoni <matthew.marangoni at gmail.com>
# Date 1516655725 28800
#      Mon Jan 22 13:15:25 2018 -0800
# Node ID e84b174c99ca39155e80dbb7458181e20190b70b
# Parent  cbf59d483c9cd94dc0fb05f1978601d02af69c20
Optimized murmurhash performance.

Improved performance for little endian machines.

diff -r cbf59d483c9c -r e84b174c99ca src/core/ngx_murmurhash.c
--- a/src/core/ngx_murmurhash.c	Tue Jan 16 13:52:03 2018 +0300
+++ b/src/core/ngx_murmurhash.c	Mon Jan 22 13:15:25 2018 -0800
@@ -16,10 +16,14 @@
     h = 0 ^ len;
 
     while (len >= 4) {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+        k = *(u_int32_t*)data;
+#else
         k  = data[0];
         k |= data[1] << 8;
         k |= data[2] << 16;
         k |= data[3] << 24;
+#endif
 
         k *= 0x5bd1e995;
         k ^= k >> 24;


More information about the nginx-devel mailing list