[Openmcl-devel] char= slower than eql?

Gary Byers gb at clozure.com
Sat Apr 9 20:21:34 UTC 2005



On Sat, 9 Apr 2005, David Tolpin wrote:

> This is consistent (I wrote the loop to avoid optimizations of constant
> expressions), and this is the cause. Why is char= slower than eql? Two
> times slower, actually:

Because CHAR= takes an &REST arg (typically containing exactly one
element), and nothing bothers to optimize for the 2-argument case.

(I would say "... and because nobody's complained about it", but I
don't think that that's true.  It'd be more accurate to say "... and
because when people have complained about it, I've forgotten to fix
it ...)


I think that just trying to catch the 2-argument case in a compiler
macro:

(define-compiler-macro char= (&whole call ch &optional (other nil other-p) &rest others)
  (if (null others)
    (if other-p
      `(= (the fixnum (char-code ,ch)) (the fixnum (char-code ,other)))
      `(progn (char-code ,ch) t))
    call))

would speed things up substantially (you might not see that under the
optimize settings you were using, but you were presumably just using
them to isolate the problem.)




More information about the Openmcl-devel mailing list