<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Questions without answers in core.match</title>
<link>https://ask.clojure.org/index.php/unanswered/contrib-libs/core-match</link>
<description></description>
<item>
<title>Can core.match LiteralPattern emit more specialized code?</title>
<link>https://ask.clojure.org/index.php/9909/can-core-match-literalpattern-emit-more-specialized-code</link>
<description>&lt;p&gt;Hello,&lt;br&gt;
Looking at the code emitted by core.match, I see that literals are always compared using &lt;code&gt;=&lt;/code&gt;. &lt;br&gt;
While it works, wouldn't it be faster to specialize equality for different literals, such as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (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)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(snippet added to &lt;code&gt;LiteralPattern&lt;/code&gt; cond.&lt;/p&gt;
&lt;p&gt;Crude benchmarks show it's faster than &lt;code&gt;=&lt;/code&gt; and all the tests pass, too.&lt;/p&gt;
&lt;p&gt;Think this warrants a patch?&lt;/p&gt;
</description>
<category>core.match</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9909/can-core-match-literalpattern-emit-more-specialized-code</guid>
<pubDate>Tue, 01 Dec 2020 07:29:48 +0000</pubDate>
</item>
</channel>
</rss>