File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -3050,16 +3050,27 @@ reduces them without incurring seq initialization"
3050
3050
(defn str
3051
3051
" With no args, returns the empty string. With one arg x, returns
3052
3052
x.toString(). (str nil) returns the empty string. With more than
3053
- one arg, returns the concatenation of the str values of the args."
3054
- ([] " " )
3055
- ([x] (if (nil? x)
3056
- " "
3057
- (.join #js [x] " " )))
3058
- ([x & ys]
3059
- (loop [sb (StringBuffer. (str x)) more ys]
3060
- (if more
3061
- (recur (. sb (append (str (first more)))) (next more))
3062
- (.toString sb)))))
3053
+ one arg, returns the concatenation of the str values of the args.
3054
+ @param x
3055
+ @param {...*} var_args"
3056
+ [x var-args]
3057
+ (cond
3058
+ ; ; works whether x is undefined or null (cljs nil)
3059
+ (nil? x) " "
3060
+ ; ; if we have no more parameters, return
3061
+ (undefined? var-args) (.join #js [x] " " )
3062
+ ; ; var arg case without relying on CLJS fn machinery which creates
3063
+ ; ; a circularity via IndexedSeq
3064
+ :else
3065
+ (let [sb (StringBuffer. )
3066
+ args (js-arguments )
3067
+ len (alength args)]
3068
+ (loop [i 1 ]
3069
+ (if (< i len)
3070
+ (do
3071
+ (.append sb (cljs.core/str (aget args i)))
3072
+ (recur (inc i)))
3073
+ (.toString sb))))))
3063
3074
3064
3075
(defn subs
3065
3076
" Returns the substring of s beginning at start inclusive, and ending
Original file line number Diff line number Diff line change 854
854
([x]
855
855
(if (typed-expr? &env x '#{string})
856
856
x
857
- (string-expr (core/list 'js* " cljs.core.str.cljs$core$IFn$_invoke$arity$1 (~{})" x))))
857
+ (string-expr (core/list 'js* " cljs.core.str(~{})" x))))
858
858
([x & ys]
859
859
(core/let [interpolate (core/fn [x]
860
860
(if (typed-expr? &env x '#{string clj-nil})
861
861
" ~{}"
862
- " cljs.core.str.cljs$core$IFn$_invoke$arity$1 (~{})" ))
862
+ " cljs.core.str(~{})" ))
863
863
strs (core/->> (core/list* x ys)
864
864
(map interpolate)
865
865
(interpose " ," )
You can’t perform that action at this time.
0 commit comments