Remove redundant LENGTH calls in NSUBSTITUTE[-IF[-NOT]]
authorJan Moringen <jmoringe@techfak.uni-bielefeld.de>
Mon, 4 Mar 2013 10:26:35 +0000 (11:26 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Fri, 22 Mar 2013 15:13:15 +0000 (15:13 +0000)
commit3cd426802c5f093d8d07042b9f180e38b8631c0b
treec6774b33973a23299c6733ca6dd80d46fa16ce09
parentead91228b6f2c70eb93978885f213e89b765e851
Remove redundant LENGTH calls in NSUBSTITUTE[-IF[-NOT]]

NSUBSTITUTE, NSUBSTITUTE-IF and NSUBSTITUTE-IF used to contain

  (let ((length (length sequence))) ...

in the code path for lists. In the macroexpansion it became clear that
this recomputed and shadowed the LENGTH variables already established
by DEFINE-SEQUENCE-TRAVERSER.

A very brief test with list lengths between 5 and 500 suggests that
the speedup produced by removing the redundant computation can be
around 5 to 20 %.
src/code/seq.lisp