Skip to content

Commit 4f37076

Browse files
committed
don't invoke load-core from analyze-form, unroll emits & emitln
1 parent 980d1fa commit 4f37076

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3804,7 +3804,6 @@
38043804

38053805
#?(:clj
38063806
(defn analyze-form [env form name opts]
3807-
(load-core)
38083807
(cond
38093808
(symbol? form) (analyze-symbol env form)
38103809
(and (seq? form) (seq form)) (analyze-seq env form name opts)

src/main/clojure/cljs/compiler.cljc

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,25 +197,35 @@
197197
(sorted-map))))))))))
198198
(emit* ast))
199199

200-
(defn emits [& xs]
201-
(doseq [^Object x xs]
202-
(cond
203-
(nil? x) nil
204-
#?(:clj (map? x) :cljs (ana/cljs-map? x)) (emit x)
205-
#?(:clj (seq? x) :cljs (ana/cljs-seq? x)) (apply emits x)
206-
#?(:clj (fn? x) :cljs ^boolean (goog/isFunction x)) (x)
207-
:else (let [^String s (cond-> x (not (string? x)) .toString)]
200+
(defn emits
201+
([])
202+
([^Object a]
203+
(cond
204+
(nil? a) nil
205+
#?(:clj (map? a) :cljs (ana/cljs-map? a)) (emit a)
206+
#?(:clj (seq? a) :cljs (ana/cljs-seq? a)) (apply emits a)
207+
#?(:clj (fn? a) :cljs ^boolean (goog/isFunction a)) (a)
208+
:else (let [^String s (cond-> a (not (string? a)) .toString)]
208209
(when-not (nil? *source-map-data*)
209210
(swap! *source-map-data*
210211
update-in [:gen-col] #(+ % (count s))))
211212
#?(:clj (.write ^Writer *out* s)
212-
:cljs (print s)))))
213-
nil)
214-
215-
(defn emitln [& xs]
216-
(apply emits xs)
217-
(binding [*flush-on-newline* false]
218-
(println))
213+
:cljs (print s))))
214+
nil)
215+
([a b]
216+
(emits a) (emits b))
217+
([a b c]
218+
(emits a) (emits b) (emits c))
219+
([a b c d]
220+
(emits a) (emits b) (emits c) (emits d))
221+
([a b c d e]
222+
(emits a) (emits b) (emits c) (emits d) (emits e))
223+
([a b c d e & xs]
224+
(emits a) (emits b) (emits c) (emits d) (emits e)
225+
(doseq [x xs] (emits x))))
226+
227+
(defn ^:private _emitln []
228+
(newline)
219229
(when *source-map-data*
220230
(swap! *source-map-data*
221231
(fn [{:keys [gen-line] :as m}]
@@ -224,6 +234,23 @@
224234
:gen-col 0))))
225235
nil)
226236

237+
(defn emitln
238+
([] (_emitln))
239+
([a]
240+
(emits a) (_emitln))
241+
([a b]
242+
(emits a) (emits b) (_emitln))
243+
([a b c]
244+
(emits a) (emits b) (emits c) (_emitln))
245+
([a b c d]
246+
(emits a) (emits b) (emits c) (emits d) (_emitln))
247+
([a b c d e]
248+
(emits a) (emits b) (emits c) (emits d) (emits e) (_emitln))
249+
([a b c d e & xs]
250+
(emits a) (emits b) (emits c) (emits d) (emits e)
251+
(doseq [x xs] (emits x))
252+
(_emitln)))
253+
227254
(defn ^String emit-str [expr]
228255
(with-out-str (emit expr)))
229256

0 commit comments

Comments
 (0)