Welcome! Please see the About page for a little more info on how this works.

+3 votes
in core.match by

Hello,
Looking at the code emitted by core.match, I see that literals are always compared using =.
While it works, wouldn't it be faster to specialize equality for different literals, such as:

 (number? l) `(and (number? ~ocr) (== ~l ~ocr))
 (keyword? l) `(identical? ~l ~ocr)
 (nil? l) `(nil? ~ocr)
 (true? l) `(true? ~ocr)
 (false? l) `(false? ~ocr)
 (string? l) `(.equals ~l ~ocr)

(snippet added to LiteralPattern cond.

Crude benchmarks show it's faster than = and all the tests pass, too.

Think this warrants a patch?

Please log in or register to answer this question.

...