From: Christophe Rhodes Date: Mon, 30 Sep 2013 14:46:26 +0000 (+0100) Subject: improve SXHASH on fixnums X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=236acc699ec1b5996e04f3f30d2859803e54e5ea;p=sbcl.git improve SXHASH on fixnums Remove one redundant LOGAND; also, use the whole of the fixnum range on 64-bit platforms. --- diff --git a/NEWS b/NEWS index 4bdd1df..cd406a0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ changes relative to sbcl-1.1.12: * optimization: better distribution of SXHASH over small conses of related values. (lp#309443) + * other improvements to SXHASH: + ** use the whole of the positive-fixnum range for SXHASH of fixnums changes in sbcl-1.1.12 relative to sbcl-1.1.11: * enhancement: Add sb-bsd-sockets:socket-shutdown, for calling diff --git a/src/code/sxhash.lisp b/src/code/sxhash.lisp index abe8199..6b09f00 100644 --- a/src/code/sxhash.lisp +++ b/src/code/sxhash.lisp @@ -38,10 +38,9 @@ ;;; SXHASH of FIXNUM values is defined as a DEFTRANSFORM because it's so ;;; simple. (deftransform sxhash ((x) (fixnum)) - '(logand most-positive-fixnum - (logxor (ash (logand x (ash most-positive-fixnum -4)) 4) - (logand (ash x -1) most-positive-fixnum) ; to get sign bit into hash - 361475658))) + (let ((c (logand 1193941380939624010 sb!xc:most-positive-fixnum))) + ;; shift by -1 to get sign bit into hash + `(logand (logxor (ash x 4) (ash x -1) ,c) sb!xc:most-positive-fixnum))) ;;; SXHASH of SIMPLE-BIT-VECTOR values is defined as a DEFTRANSFORM ;;; because it is endian-dependent.