Skip to content

Commit 5c12d66

Browse files
mfikesswannodette
authored andcommitted
CLJS-2314: Eliminate str call on literal strings in str macro
1 parent 06d81bc commit 5c12d66

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,12 @@
819819
(core/inc (core/quot c 32)))))
820820

821821
(core/defmacro str [& xs]
822-
(core/let [strs (core/->> (repeat (count xs) "cljs.core.str.cljs$core$IFn$_invoke$arity$1(~{})")
822+
(core/let [interpolate (core/fn [x]
823+
(if (core/string? x)
824+
"~{}"
825+
"cljs.core.str.cljs$core$IFn$_invoke$arity$1(~{})"))
826+
strs (core/->> xs
827+
(map interpolate)
823828
(interpose ",")
824829
(apply core/str))]
825830
(list* 'js* (core/str "[" strs "].join('')") xs)))

0 commit comments

Comments
 (0)