diff --git a/mercurial/thirdparty/xdiff/xutils.c b/mercurial/thirdparty/xdiff/xutils.c --- a/mercurial/thirdparty/xdiff/xutils.c +++ b/mercurial/thirdparty/xdiff/xutils.c @@ -22,10 +22,13 @@ #include #include -#include "xinclude.h" +/* Define XXHASH functions in a custom namespace */ +#define XXH_NAMESPACE XDIFF_ +#define XXH_PRIVATE_API +#include "thirdparty/xxhash/xxhash.h" - +#include "xinclude.h" long xdl_bogosqrt(long n) { long i; @@ -299,19 +302,16 @@ } unsigned long xdl_hash_record(char const **data, char const *top, long flags) { - unsigned long ha = 5381; + XXH32_hash_t h; char const *ptr = *data; if (flags & XDF_WHITESPACE_FLAGS) return xdl_hash_record_with_whitespace(data, top, flags); - for (; ptr < top && *ptr != '\n'; ptr++) { - ha += (ha << 5); - ha ^= (unsigned long) *ptr; - } + for (; ptr < top && *ptr != '\n'; ptr++) { } + h = XDIFF_XXH32(*data, ptr - *data + 1, 0); *data = ptr < top ? ptr + 1: ptr; - - return ha; + return h; } unsigned int xdl_hashbits(unsigned int size) { diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -871,9 +871,13 @@ include_dirs=common_include_dirs, depends=common_depends), Extension('mercurial.cext.bdiff', ['mercurial/bdiff.c', - 'mercurial/cext/bdiff.c'] + xdiff_srcs, + 'mercurial/cext/bdiff.c', + 'mercurial/thirdparty/xxhash/xxhash.c', + ] + xdiff_srcs, include_dirs=common_include_dirs, - depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers), + depends=common_depends + ['mercurial/bdiff.h', + 'mercurial/thirdparty/xxhash/xxhash.h', + ] + xdiff_headers), Extension('mercurial.cext.diffhelpers', ['mercurial/cext/diffhelpers.c'], include_dirs=common_include_dirs, depends=common_depends),