From 81d2ddedbb6eb9b218d38dbc9ec766a6e13307ed Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 9 Aug 2014 23:51:10 -0700 Subject: [PATCH] Clamp quasi-murmurhash output --- minimart/treap.rkt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/minimart/treap.rkt b/minimart/treap.rkt index 388ecfd..8a33691 100644 --- a/minimart/treap.rkt +++ b/minimart/treap.rkt @@ -75,9 +75,11 @@ (define hash0 (* c2 (bitwise-ior (arithmetic-shift k r1) (arithmetic-shift k (- 32 r1))))) (define hash1 (+ n (* m (bitwise-ior (arithmetic-shift hash0 r2) (arithmetic-shift hash0 (- 32 r2)))))) - (define hash2 (* #x85ebca6b (bitwise-xor hash1 (arithmetic-shift hash1 -16)))) - (define hash3 (* #xc2b2ae35 (bitwise-xor hash2 (arithmetic-shift hash1 -13)))) - (bitwise-xor hash2 (arithmetic-shift hash1 -16))) + (define hash2 + (bitwise-and #xffffffff (* #x85ebca6b (bitwise-xor hash1 (arithmetic-shift hash1 -16))))) + (define hash3 + (bitwise-and #xffffffff (* #xc2b2ae35 (bitwise-xor hash2 (arithmetic-shift hash2 -13))))) + (bitwise-xor hash3 (arithmetic-shift hash3 -16))) (define (treap-insert t key value [priority (default-priority key)]) (match-define (treap order root oldsize) t)