From: Nikodemus S. <de...@us...> - 2008-06-30 10:34:07
|
Update of /cvsroot/sbcl/sbcl/src/code In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv7860/src/code Modified Files: target-extensions.lisp target-hash-table.lisp Log Message: 1.0.18.7: just one POWER-OF-TWO-CEILING, thank you * We had two, of which CEIL-POWER-OF-TWO with arguments that already were powers of two returned the *next* power of two, and not the argument, whereas POWER-OF-TWO-CEILING returned the argument if it already was a power of two. As far as I can tell returning the argument is fine in those case in places where CEIL-POWER-OF-TWO was used, so replace it with POWER-OF-TWO-CEILING -- which really doesn't have to be inline. Index: target-extensions.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/target-extensions.lisp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- target-extensions.lisp 10 Jan 2008 11:32:48 -0000 1.16 +++ target-extensions.lisp 30 Jun 2008 10:34:03 -0000 1.17 @@ -119,3 +119,8 @@ (%shrink-vector string size) string))) ,@body)))) + +;;; The smallest power of two that is equal to or greater than X. +(defun power-of-two-ceiling (x) + (declare (index x)) + (ash 1 (integer-length (1- x)))) Index: target-hash-table.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/target-hash-table.lisp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- target-hash-table.lisp 14 Feb 2008 16:40:47 -0000 1.47 +++ target-hash-table.lisp 30 Jun 2008 10:34:03 -0000 1.48 @@ -108,10 +108,6 @@ (t (eq-hash key)))) -(defun ceil-power-of-two (num) - (declare (type index num)) - (ash 1 (integer-length num))) - (declaim (inline index-for-hashing)) (defun index-for-hashing (hash length) (declare (type hash hash length)) @@ -234,8 +230,8 @@ ;; Note that this has not yet been audited for ;; correctness. It just seems to work. -- CSR, 2002-11-02 (scaled-size (truncate (/ (float size+1) rehash-threshold))) - (length (ceil-power-of-two (max scaled-size - (1+ +min-hash-table-size+)))) + (length (power-of-two-ceiling (max scaled-size + (1+ +min-hash-table-size+)))) (index-vector (make-array length :element-type '(unsigned-byte #.sb!vm:n-word-bits) @@ -326,7 +322,7 @@ (old-hash-vector (hash-table-hash-vector table)) (old-size (length old-next-vector)) (new-size - (ceil-power-of-two + (power-of-two-ceiling (let ((rehash-size (hash-table-rehash-size table))) (etypecase rehash-size (fixnum |