Skip to content

Commit 3453f86

Browse files
author
Junio C Hamano
committed
Merge branch 'maint'
* maint: Fix hash function in xdiff library
2 parents b32db4d + 9de0834 commit 3453f86

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

xdiff/xmacros.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
#define XMACROS_H
2525

2626

27-
#define GR_PRIME 0x9e370001UL
2827

2928

3029
#define XDL_MIN(a, b) ((a) < (b) ? (a): (b))
3130
#define XDL_MAX(a, b) ((a) > (b) ? (a): (b))
3231
#define XDL_ABS(v) ((v) >= 0 ? (v): -(v))
3332
#define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9')
34-
#define XDL_HASHLONG(v, b) (((unsigned long)(v) * GR_PRIME) >> ((CHAR_BIT * sizeof(unsigned long)) - (b)))
33+
#define XDL_ADDBITS(v,b) ((v) + ((v) >> (b)))
34+
#define XDL_MASKBITS(b) ((1UL << (b)) - 1)
35+
#define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b))
3536
#define XDL_PTRFREE(p) do { if (p) { xdl_free(p); (p) = NULL; } } while (0)
3637
#define XDL_LE32_PUT(p, v) \
3738
do { \

0 commit comments

Comments
 (0)