0.8.10.21:
authorChristophe Rhodes <csr21@cam.ac.uk>
Wed, 12 May 2004 15:49:01 +0000 (15:49 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Wed, 12 May 2004 15:49:01 +0000 (15:49 +0000)
Optimize CLRHASH a little (Juho Snellman sbcl-devel 2004-05-11)
... DECLARE (OPTIMIZE SPEED) probably makes a difference;
... rewriting DOs as FILL probably doesn't really, but looks
better;
... might as well put the AVER before rather than after the FILL.

src/code/target-hash-table.lisp
version.lisp-expr

index c28e640..38bae0c 100644 (file)
   #!+sb-doc
   "This removes all the entries from HASH-TABLE and returns the hash table
    itself."
+  (declare (optimize speed))
   (let* ((kv-vector (hash-table-table hash-table))
-        (kv-length (length kv-vector))
         (next-vector (hash-table-next-vector hash-table))
         (hash-vector (hash-table-hash-vector hash-table))
         (size (length next-vector))
-        (index-vector (hash-table-index-vector hash-table))
-        (length (length index-vector)))
+        (index-vector (hash-table-index-vector hash-table)))
     ;; Disable GC tricks.
     (set-header-data kv-vector sb!vm:vector-normal-subtype)
     ;; Mark all slots as empty by setting all keys and values to magic
     ;; tag.
-    (do ((i 2 (1+ i)))
-       ((>= i kv-length))
-      (setf (aref kv-vector i) +empty-ht-slot+))
     (aver (eq (aref kv-vector 0) hash-table))
+    (fill kv-vector +empty-ht-slot+ :start 2)
     ;; Set up the free list, all free.
     (do ((i 1 (1+ i)))
        ((>= i (1- size)))
     (setf (hash-table-next-free-kv hash-table) 1)
     (setf (hash-table-needing-rehash hash-table) 0)
     ;; Clear the index-vector.
-    (dotimes (i length)
-      (setf (aref index-vector i) 0))
+    (fill index-vector 0)
     ;; Clear the hash-vector.
     (when hash-vector
-      (dotimes (i size)
-       (setf (aref hash-vector i) +magic-hash-vector-value+))))
+      (fill hash-vector +magic-hash-vector-value+)))
   (setf (hash-table-number-entries hash-table) 0)
   hash-table)
 \f
index 9d607a1..ba36119 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.10.20"
+"0.8.10.21"