@@ -10495,6 +10495,13 @@ reduces them without incurring seq initialization"
10495
10495
(doseq [s ss]
10496
10496
(-write writer s)))
10497
10497
10498
+ (defn write-all-array [writer arr]
10499
+ (let [len (alength arr)]
10500
+ (loop [i 0 ]
10501
+ (when (< i len)
10502
+ (-write writer (aget arr i))
10503
+ (recur (inc i))))))
10504
+
10498
10505
(defn string-print [x]
10499
10506
(when (nil? *print-fn*)
10500
10507
(throw (js/Error. " No *print-fn* fn set for evaluation environment" )))
@@ -10516,10 +10523,9 @@ reduces them without incurring seq initialization"
10516
10523
10517
10524
(defn ^:private quote-string
10518
10525
[s]
10519
- (str \"
10520
- (.replace s (js/RegExp " [\\\\\"\b\f\n\r\t ]" " g" )
10521
- (fn [match] (unchecked-get char-escapes match)))
10522
- \"))
10526
+ (let [s' ^string (.replace s (js/RegExp " [\\\\\"\b\f\n\r\t ]" " g" )
10527
+ (fn [match] (unchecked-get char-escapes match)))]
10528
+ (str \" s' \")))
10523
10529
10524
10530
(declare print-map )
10525
10531
@@ -10548,23 +10554,27 @@ reduces them without incurring seq initialization"
10548
10554
(-pr-writer obj writer opts)
10549
10555
10550
10556
(or (true ? obj) (false ? obj))
10551
- (-write writer (str obj))
10557
+ (-write writer (.toString obj))
10552
10558
10553
10559
(number? obj)
10554
10560
(-write writer
10555
10561
(cond
10556
10562
^boolean (js/isNaN obj) " ##NaN"
10557
10563
(identical? obj js/Number.POSITIVE_INFINITY) " ##Inf"
10558
10564
(identical? obj js/Number.NEGATIVE_INFINITY) " ##-Inf"
10559
- :else (str obj)))
10565
+ :else (.toString obj)))
10560
10566
10561
10567
(object? obj)
10562
10568
(do
10563
10569
(-write writer " #js " )
10564
10570
(print-map
10565
- (map (fn [k]
10566
- (MapEntry. (cond-> k (some? (re-matches #"[A-Za-z_\*\+\? !\- '][\w\*\+\? !\- ']*" k)) keyword) (unchecked-get obj k) nil ))
10567
- (js-keys obj))
10571
+ (prim-seq
10572
+ (.map
10573
+ (fn [k]
10574
+ (MapEntry.
10575
+ (cond-> k (some? (re-matches #"[A-Za-z_\*\+\? !\- '][\w\*\+\? !\- ']*" k)) keyword)
10576
+ (unchecked-get obj k) nil ))
10577
+ (js-keys obj)))
10568
10578
pr-writer writer opts))
10569
10579
10570
10580
(array? obj)
@@ -10580,45 +10590,48 @@ reduces them without incurring seq initialization"
10580
10590
name (if (or (nil? name) (gstring/isEmpty name))
10581
10591
" Function"
10582
10592
name)]
10583
- (write-all writer " #object[" name
10584
- (if *print-fn-bodies*
10585
- (str " \" " (str obj) " \" " )
10586
- " " )
10587
- " ]" ))
10593
+ (write-all-array writer
10594
+ (array
10595
+ " #object[" name
10596
+ (if *print-fn-bodies*
10597
+ (str " \" " ^string (.toString obj) " \" " )
10598
+ " " )
10599
+ " ]" )))
10588
10600
10589
10601
(instance? js/Date obj)
10590
10602
(let [normalize (fn [n len]
10591
- (loop [ns (str n)]
10603
+ (loop [ns (.toString n)]
10592
10604
(if (< (count ns ) len)
10593
- (recur (str " 0" ns ))
10605
+ (recur (str " 0" ^string ns ))
10594
10606
ns )))]
10595
- (write-all writer
10596
- " #inst \" "
10597
- (normalize (.getUTCFullYear obj) 4 ) " -"
10598
- (normalize (inc (.getUTCMonth obj)) 2 ) " -"
10599
- (normalize (.getUTCDate obj) 2 ) " T"
10600
- (normalize (.getUTCHours obj) 2 ) " :"
10601
- (normalize (.getUTCMinutes obj) 2 ) " :"
10602
- (normalize (.getUTCSeconds obj) 2 ) " ."
10603
- (normalize (.getUTCMilliseconds obj) 3 ) " -"
10604
- " 00:00\" " ))
10605
-
10606
- (regexp? obj) (write-all writer " #\" " (.-source obj) " \" " )
10607
-
10608
- (js-symbol? obj) (write-all writer " #object[" (.toString obj) " ]" )
10607
+ (write-all-array writer
10608
+ (array
10609
+ " #inst \" "
10610
+ (normalize (.getUTCFullYear obj) 4 ) " -"
10611
+ (normalize (inc (.getUTCMonth obj)) 2 ) " -"
10612
+ (normalize (.getUTCDate obj) 2 ) " T"
10613
+ (normalize (.getUTCHours obj) 2 ) " :"
10614
+ (normalize (.getUTCMinutes obj) 2 ) " :"
10615
+ (normalize (.getUTCSeconds obj) 2 ) " ."
10616
+ (normalize (.getUTCMilliseconds obj) 3 ) " -"
10617
+ " 00:00\" " )))
10618
+
10619
+ (regexp? obj) (write-all-array writer (array " #\" " (.-source obj) " \" " ))
10620
+
10621
+ (js-symbol? obj) (write-all-array writer (array " #object[" (.toString obj) " ]" ))
10609
10622
10610
10623
:else
10611
10624
(if (some-> obj .-constructor .-cljs$lang$ctorStr)
10612
- (write-all writer
10613
- " #object[" (.replace (.. obj -constructor -cljs$lang$ctorStr)
10614
- (js/RegExp. " /" " g" ) " ." ) " ]" )
10625
+ (write-all-array writer
10626
+ ( array " #object[" (.replace (.. obj -constructor -cljs$lang$ctorStr)
10627
+ (js/RegExp. " /" " g" ) " ." ) " ]" ) )
10615
10628
(let [name (some-> obj .-constructor .-name)
10616
10629
name (if (or (nil? name) (gstring/isEmpty name))
10617
10630
" Object"
10618
10631
name)]
10619
10632
(if (nil? (. obj -constructor))
10620
- (write-all writer " #object[" name " ]" )
10621
- (write-all writer " #object[" name " " (str obj) " ]" ))))))))
10633
+ (write-all-array writer ( array " #object[" name " ]" ) )
10634
+ (write-all-array writer ( array " #object[" name " " (.toString obj) " ]" ) ))))))))
10622
10635
10623
10636
(defn- pr-writer
10624
10637
" Prefer this to pr-seq, because it makes the printing function
@@ -10744,15 +10757,15 @@ reduces them without incurring seq initialization"
10744
10757
(recur new-ns entries (assoc lm (strip-ns k) v)))))
10745
10758
[ns lm]))))
10746
10759
10747
- (defn print-prefix-map [prefix m print-one writer opts]
10760
+ (defn print-prefix-map [^string prefix m print-one writer opts]
10748
10761
(pr-sequential-writer
10749
10762
writer
10750
10763
(fn [e w opts]
10751
10764
(do (print-one (key e) w opts)
10752
10765
(-write w \space)
10753
10766
(print-one (val e) w opts)))
10754
10767
(str prefix " {" ) " , " " }"
10755
- opts (seq m)))
10768
+ opts (- seq m)))
10756
10769
10757
10770
(defn print-map [m print-one writer opts]
10758
10771
(let [[ns lift-map] (when (map? m)
0 commit comments