Skip to content

Commit 61829b1

Browse files
committed
* allow numbers to be optimized wtih calls to str
* fixes invoke to cljs.core/str in protocol fns * add another trivial dce test w/ a protocol fn
1 parent 9b4225e commit 61829b1

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,12 +852,12 @@
852852
(core/defmacro str
853853
([] "")
854854
([x]
855-
(if (typed-expr? &env x '#{string})
855+
(if (typed-expr? &env x '#{string number})
856856
x
857857
(string-expr (core/list 'js* "cljs.core.str.cljs$core$IFn$_invoke$arity$1(~{})" x))))
858858
([x & ys]
859859
(core/let [interpolate (core/fn [x]
860-
(if (typed-expr? &env x '#{string clj-nil})
860+
(if (typed-expr? &env x '#{string number clj-nil})
861861
"~{}"
862862
"cljs.core.str.cljs$core$IFn$_invoke$arity$1(~{})"))
863863
strs (core/->> (core/list* x ys)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(ns trivial.core2)
2+
3+
(. js/console (-lookup 1 2))

src/test/clojure/cljs/build_api_tests.clj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,19 @@
720720
(build/build (build/inputs (io/file inputs "trivial/core.cljs")) opts cenv)
721721
(is (< (.length out-file) 10000))))
722722

723+
(deftest trivial-output-size-protocol
724+
(let [out (.getPath (io/file (test/tmp-dir) "trivial-output-protocol-test-out"))
725+
out-file (io/file out "main.js")
726+
{:keys [inputs opts]} {:inputs (str (io/file "src" "test" "cljs_build"))
727+
:opts {:main 'trivial.core2
728+
:output-dir out
729+
:output-to (.getPath out-file)
730+
:optimizations :advanced}}
731+
cenv (env/default-compiler-env)]
732+
(test/delete-out-files out)
733+
(build/build (build/inputs (io/file inputs "trivial/core2.cljs")) opts cenv)
734+
(is (< (.length out-file) 10000))))
735+
723736
(deftest cljs-3255-nil-inputs-build
724737
(let [out (.getPath (io/file (test/tmp-dir) "3255-test-out"))
725738
out-file (io/file out "main.js")

0 commit comments

Comments
 (0)