Fork me on GitHub

I’m currently trying to track down a weird edge case in the compiler, noticed a few of reader conditionals, eg. cljs.analyzer/resolve-var


(if #?(:clj  (= "js" (namespace sym))
            :cljs (identical? "js" (namespace sym)))


is = so much worse performance wise in JS or why the identical??


@thheller After self-hosted ClojureScript was introduced, David went through an optimization effort, tweaking things to try to get compilation to run faster


@thheller expanding very slightly on mfikes' point ... being able to use identical? instead of = is an optimsation which exploits the underlying platform's treatment of strings. In js environments, strings are interned whereas, on the JVM, they are not. For example ... on a js env this will test true, whereas on the JVM it is will test false: (identical? "hello" (str "hell" "o")) BTW, I'm yet to see someone point to a spec which says that string interning is guaranteed in javascript but, empirically, with all implementations doing it, it seems fairly solid at this point.