X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-hash-table.lisp;h=b98c33d4240ad5f93b2d24fbc919799bcd6f8360;hb=9faac297a083fbc59011e54ca6ccdc8c611e7ffb;hp=d3a9bdb57d439369bc8e4d6dbc63d3099dfc704d;hpb=bc1783335d78be988465e4fc7cf9c5fdb88a3fa4;p=sbcl.git diff --git a/src/code/target-hash-table.lisp b/src/code/target-hash-table.lisp index d3a9bdb..b98c33d 100644 --- a/src/code/target-hash-table.lisp +++ b/src/code/target-hash-table.lisp @@ -82,10 +82,6 @@ (defconstant +min-hash-table-size+ 16) (defconstant +min-hash-table-rehash-threshold+ (float 1/16 1.0)) -;; as explained by pmai on openprojects #lisp IRC 2002-07-30: #x80000000 -;; is bigger than any possible nonEQ hash value, and thus indicates an -;; empty slot; and EQ hash tables don't use HASH-TABLE-HASH-VECTOR -(defconstant +magic-hash-vector-value+ #x80000000) (defun make-hash-table (&key (test 'eql) (size +min-hash-table-size+) @@ -436,7 +432,7 @@ ;; First check the cache. Use EQ here for speed. (let ((cache (hash-table-cache hash-table)) (table (hash-table-table hash-table))) - + (if (and cache (< cache (length table)) (eq (aref table cache) key)) (values (aref table (1+ cache)) t) @@ -510,11 +506,11 @@ (hash-vector (hash-table-hash-vector hash-table)) (test-fun (hash-table-test-fun hash-table))) (declare (type index index)) - + (cond ((or eq-based (not hash-vector)) (when eq-based (set-header-data kv-vector sb!vm:vector-valid-hashing-subtype)) - + ;; Search next-vector chain for a matching key. (do ((next next (aref next-vector next))) ((zerop next)) @@ -536,7 +532,7 @@ (setf (hash-table-cache hash-table) (* 2 next)) (setf (aref kv-vector (1+ (* 2 next))) value) (return-from %puthash value))))) - + ;; Pop a KV slot off the free list (let ((free-kv-slot (hash-table-next-free-kv hash-table))) ;; Double-check for overflow. @@ -544,17 +540,17 @@ (setf (hash-table-next-free-kv hash-table) (aref next-vector free-kv-slot)) (incf (hash-table-number-entries hash-table)) - + (setf (hash-table-cache hash-table) (* 2 free-kv-slot)) (setf (aref kv-vector (* 2 free-kv-slot)) key) (setf (aref kv-vector (1+ (* 2 free-kv-slot))) value) - + ;; Setup the hash-vector if necessary. (when hash-vector (if (not eq-based) (setf (aref hash-vector free-kv-slot) hashing) (aver (= (aref hash-vector free-kv-slot) +magic-hash-vector-value+)))) - + ;; Push this slot into the next chain. (setf (aref next-vector free-kv-slot) next) (setf (aref index-vector index) free-kv-slot))))))) @@ -575,7 +571,7 @@ ((not (zerop (hash-table-needing-rehash hash-table))) (flush-needing-rehash hash-table))) - ;; For now, just clear the cache + ;; For now, just clear the cache (setf (hash-table-cache hash-table) nil) ;; Search for key in the hash table. @@ -725,14 +721,12 @@ (def!method print-object ((hash-table hash-table) stream) (declare (type stream stream)) - (cond ((not *print-readably*) + (cond ((or (not *print-readably*) (not *read-eval*)) (print-unreadable-object (hash-table stream :type t :identity t) (format stream ":TEST ~S :COUNT ~S" (hash-table-test hash-table) (hash-table-count hash-table)))) - ((not *read-eval*) - (error "can't print hash tables readably without *READ-EVAL*")) (t (with-standard-io-syntax (format stream