Skip to content

Commit aa00c03

Browse files
mfikesswannodette
authored andcommitted
CLJS-1932: Self-host: Perf regression macroexpand-check
Addresses a self-hosted perf regression obtaining cljs.spec/macroexpand-check. Previously for every macroexpansion, if cljs.spec was loaded, it would build a map of all of the vars in that namespace and then get the the var for macroexpand-check from that map. This revision avoids building the map upon every check, instead performing a cheaper find-ns-obj check to see if cljs.spec is loaded and if so, performing the same logic but within a delay so as to cache the result.
1 parent d265570 commit aa00c03

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,12 @@
29412941
:cljs ^boolean (.isMacro mvar)))
29422942
mvar)))
29432943

2944+
#?(:cljs
2945+
(let [cached-var (delay (get (ns-interns* 'cljs.spec) 'macroexpand-check))]
2946+
(defn get-macroexpand-check-var []
2947+
(when (some? (find-ns-obj 'cljs.spec))
2948+
@cached-var))))
2949+
29442950
(defn macroexpand-1*
29452951
[env form]
29462952
(let [op (first form)]
@@ -2952,7 +2958,7 @@
29522958
:cljs [do])
29532959
(let [mchk #?(:clj (some-> (find-ns 'clojure.spec)
29542960
(ns-resolve 'macroexpand-check))
2955-
:cljs (get (ns-interns* 'cljs.spec) 'macroexpand-check))
2961+
:cljs (get-macroexpand-check-var))
29562962
_ (when (some? mchk)
29572963
(mchk mac-var (next form)))
29582964
form' (try

0 commit comments

Comments
 (0)