[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Inline expansion of character comparisons
In cmpopt.lsp, the entries for char= are
(push '((t t) boolean nil nil "eql(#0,#1)")
(get 'char= 'inline-unsafe))
(push '((t t) boolean nil nil "char_code(#0)==char_code(#1)")
(get 'char= 'inline-unsafe))
(push '((character character) boolean nil nil "(#0)==(#1)")
(get 'char= 'inline-always))
The problem is that with (safety 1) the better expansion
when the arguments are known to be characters (the one
with types (character character) under inline-always)
doesn't have any effect because there's always a match
with the (t t) entry under inline-unsafe. Also, the first
entry seems to be redundant.
I think the correct inline entries should look like this:
(push '((character character) boolean nil nil "(#0)==(#1)")
(get 'char= 'inline-safe))
(push '((t t) boolean nil nil "char_code(#0)==char_code(#1)")
(get 'char= 'inline-unsafe))
(push '((character character) boolean nil nil "(#0)==(#1)")
(get 'char= 'inline-unsafe))
Also, since characters that are char= are also eq, wouldn't
a simple == test be both safer and faster than doing
char_code(#0) == char_code(#1)?
All of this applies to char/= as well.