1.0.15.11: one more slice of ASSOC micro-optimization
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 3 Mar 2008 15:13:04 +0000 (15:13 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 3 Mar 2008 15:13:04 +0000 (15:13 +0000)
commit6e332c91239622ffa95acbb3d2d69b8995265aa9
tree7ce8a0b211a9f18d9a799f207ec7d5dc50b1cb56
parent9520c5d03ff1dbc861054183eef7ab5620d3e217
1.0.15.11: one more slice of ASSOC micro-optimization

 * In %ASSOC and %ASSOC-EQ, test for equality before checking if the
   list element is NIL: in the common case only one element needs both
   tests, and even in the rare cases (looking for NIL, list contains
   several NILs) this is as fast as the old version. Common cases
   improved by ~30% by this.

   Now, finally, CL:ASSOC is as fast as

    (defun fast-assoc (item list)
      (loop for e in list
            when (eq item (car e))
            return e))

   when the type of ITEM is known to be (OR FIXNUM (NOT NUMBER)).

 * In others %ASSOC-* functions, test for existence of element only
   once (the compiler should eliminate the redundant test, though, but
   this is cleaner.)
src/code/list.lisp
version.lisp-expr