1.0.16.5: faster ADJOIN in normal speed policies
authorNikodemus Siivola <nikodemus@random-state.net>
Wed, 23 Apr 2008 15:29:28 +0000 (15:29 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Wed, 23 Apr 2008 15:29:28 +0000 (15:29 +0000)
 * Remore MAYBE-INLINE declaration, and add a compiler macro so that
   MEMBER transform is able to its job.

NEWS
src/code/list.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 1d33ffc..fb96144 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 ;;;; -*- coding: utf-8; -*-
 changes in sbcl-1.0.17 relative to 1.0.16:
+  * optimization: ADJOIN and PUSHNEW are upto ~70% faster in normal
+    SPEED policies.
   * bug fix: dynamic extent allocation of nested lists and vectors
     could leak to otherwise accessible parts.
   * bug fix: invalid optimization of heap-allocated alien variable
index ca44632..8f63226 100644 (file)
@@ -19,7 +19,7 @@
 
 (declaim (maybe-inline
           tree-equal nth %setnth nthcdr last last1 make-list append
-          nconc nconc2 member-if member-if-not tailp adjoin union
+          nconc nconc2 member-if member-if-not tailp union
           nunion intersection nintersection set-difference nset-difference
           set-exclusive-or nset-exclusive-or subsetp acons
           assoc-if assoc-if-not rassoc rassoc-if rassoc-if-not subst subst-if
   (when (and testp notp)
     (error ":TEST and :TEST-NOT were both supplied."))
   (let ((key (and key (%coerce-callable-to-fun key))))
-    (declare (inline member))
     (if (let ((key-val (apply-key key item)))
           (if notp
               (member key-val list :test-not test-not :key key)
         list
         (cons item list))))
 
+(define-compiler-macro adjoin (item list &rest keys)
+  (with-unique-names (n-item n-list)
+    `(let ((,n-item ,item)
+           (,n-list ,list))
+       (if (member ,n-item ,n-list ,@keys)
+           ,n-list
+           (cons ,n-item ,n-list)))))
+
 (defconstant +list-based-union-limit+ 80)
 
 (defun union (list1 list2 &key key (test #'eql testp) (test-not nil notp))
index bfc9de7..70ae363 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".)
-"1.0.16.4"
+"1.0.16.5"