From e58a3d9dda5b7157c08da8d354e530071bdfa397 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 5 Apr 2021 11:39:17 -0600 Subject: [PATCH] cs: adapt (unused) Patricia trie implementation for negative hash codes The hashing protocol has been adjusted since the Patricia trie implementation so that the result can be negative. Force it to avoid breaking an assumption in the Patricia-trie implementation (even though this implementation is not currently used). --- racket/src/cs/rumble/patricia.ss | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/racket/src/cs/rumble/patricia.ss b/racket/src/cs/rumble/patricia.ss index 4fd2ba3734..195c7af1d6 100644 --- a/racket/src/cs/rumble/patricia.ss +++ b/racket/src/cs/rumble/patricia.ss @@ -258,10 +258,13 @@ [(eq? et 'eqv) (eqv? k1 k2)] [else (key-equal? k1 k2)])) +(define-syntax-rule (to-fxpositive e) + (fxand e (most-positive-fixnum))) + (define-syntax-rule (hash-code et k) - (cond [(eq? et 'eq) (eq-hash-code k)] - [(eq? et 'eqv) (eqv-hash-code k)] - [else (key-equal-hash-code k)])) + (cond [(eq? et 'eq) (to-fxpositive (eq-hash-code k))] + [(eq? et 'eqv) (to-fxpositive (eqv-hash-code k))] + [else (to-fxpositive (key-equal-hash-code k))])) ;; iteration (define (intmap-iterate-first t)