From: Paul F. Dietz <dietz@dl...> - 2003-08-16 12:44:46
This change was commited to early-extensions.lsp:
$ cvs diff -r1.62 early-extensions.lisp
RCS file: /cvsroot/sbcl/sbcl/src/code/early-extensions.lisp,v
retrieving revision 1.62
retrieving revision 1.63
diff -r1.62 -r1.63
< (when (eq (car pair) item)
> (when (and pair (eq (car pair) item))
This code is not as fast as it could be. NIL list elements
are rare in alists, so you should check if PAIR is NIL only
after (eq (car pair) item) is found to be true (and remember,
(car nil) == nil.) As written, PAIR is compared with NIL on
every iteration, nearly doubling the number of comparisons in the
body of the loop.
"Paul F. Dietz" <dietz@...> writes:
> < (when (eq (car pair) item)
> > (when (and pair (eq (car pair) item))
> This code is not as fast as it could be.
So it isn't. I've rewritten the test to read
(and (eq (car pair) item) (not (null pair)))
and added an explanatory comment in sbcl-0.8.2.34.
Thanks very much,
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)
Get latest updates about Open Source Projects, Conferences and News.