@@ -3614,11 +3614,12 @@ reduces them without incurring seq initialization"
3614
3614
3615
3615
(defn spread
3616
3616
[arglist]
3617
- (cond
3618
- (nil? arglist) nil
3619
- (nil? (next arglist)) (seq (first arglist))
3620
- :else (cons (first arglist)
3621
- (spread (next arglist)))))
3617
+ (when-not (nil? arglist)
3618
+ (let [n (next arglist)]
3619
+ (if (nil? n)
3620
+ (seq (first arglist))
3621
+ (cons (first arglist)
3622
+ (spread n))))))
3622
3623
3623
3624
(defn concat
3624
3625
" Returns a lazy seq representing the concatenation of the elements in the supplied colls."
@@ -3729,52 +3730,89 @@ reduces them without incurring seq initialization"
3729
3730
(gen-apply-to )
3730
3731
3731
3732
(set! *unchecked-if* true )
3733
+
3734
+ (defn- apply-to-simple
3735
+ " Internal. DO NOT USE!
3736
+ Assumes args was already called with seq beforehand!"
3737
+ ([f ^seq args]
3738
+ (if (nil? args)
3739
+ (if (.-cljs$core$IFn$_invoke$arity$0 f)
3740
+ (.cljs$core$IFn$_invoke$arity$0 f)
3741
+ (.call f f))
3742
+ (apply-to-simple f (-first args) (next args))))
3743
+ ([f a0 ^seq args]
3744
+ (if (nil? args)
3745
+ (if (.-cljs$core$IFn$_invoke$arity$1 f)
3746
+ (.cljs$core$IFn$_invoke$arity$1 f a0)
3747
+ (.call f f a0))
3748
+ (apply-to-simple f a0 (-first args) (next args))))
3749
+ ([f a0 a1 ^seq args]
3750
+ (if (nil? args)
3751
+ (if (.-cljs$core$IFn$_invoke$arity$2 f)
3752
+ (.cljs$core$IFn$_invoke$arity$2 f a0 a1)
3753
+ (.call f f a0 a1))
3754
+ (apply-to-simple f a0 a1 (-first args) (next args))))
3755
+ ([f a0 a1 a2 ^seq args]
3756
+ (if (nil? args)
3757
+ (if (.-cljs$core$IFn$_invoke$arity$3 f)
3758
+ (.cljs$core$IFn$_invoke$arity$3 f a0 a1 a2)
3759
+ (.call f f a0 a1 a2))
3760
+ (apply-to-simple f a0 a1 a2 (-first args) (next args))))
3761
+ ([f a0 a1 a2 a3 ^seq args]
3762
+ (if (nil? args)
3763
+ (if (.-cljs$core$IFn$_invoke$arity$4 f)
3764
+ (.cljs$core$IFn$_invoke$arity$4 f a0 a1 a2 a3)
3765
+ (.call f f a0 a1 a2 a3))
3766
+ (gen-apply-to-simple f 4 args))))
3767
+
3732
3768
(defn apply
3733
3769
" Applies fn f to the argument list formed by prepending intervening arguments to args."
3734
3770
([f args]
3735
- ( let [fixed-arity (.-cljs$lang$maxFixedArity f)]
3736
- ( if ( .-cljs$lang$applyTo f)
3737
- ( let [ bc (bounded-count (inc fixed-arity) args)]
3738
- (if (<= bc fixed-arity)
3739
- (apply-to f bc args)
3740
- (.cljs$lang$applyTo f args)))
3741
- ( . apply f f ( to-array args) ))))
3771
+ ( if (.-cljs$lang$applyTo f)
3772
+ ( let [fixed-arity ( .-cljs$lang$maxFixedArity f)
3773
+ bc (bounded-count (inc fixed-arity) args)]
3774
+ (if (<= bc fixed-arity)
3775
+ (apply-to f bc args)
3776
+ (.cljs$lang$applyTo f args)))
3777
+ ( apply-to-simple f ( seq args))))
3742
3778
([f x args]
3779
+ (if (.-cljs$lang$applyTo f)
3743
3780
(let [arglist (list* x args)
3744
- fixed-arity (.-cljs$lang$maxFixedArity f)]
3745
- (if (.-cljs$lang$applyTo f)
3746
- (let [bc (bounded-count (inc fixed-arity) arglist)]
3747
- (if (<= bc fixed-arity)
3748
- (apply-to f bc arglist)
3749
- (.cljs$lang$applyTo f arglist)))
3750
- (.apply f f (to-array arglist)))))
3781
+ fixed-arity (.-cljs$lang$maxFixedArity f)
3782
+ bc (inc (bounded-count fixed-arity args))]
3783
+ (if (<= bc fixed-arity)
3784
+ (apply-to f bc arglist)
3785
+ (.cljs$lang$applyTo f arglist)))
3786
+ (apply-to-simple f x (seq args))))
3751
3787
([f x y args]
3788
+ (if (.-cljs$lang$applyTo f)
3752
3789
(let [arglist (list* x y args)
3753
- fixed-arity (.-cljs$lang$maxFixedArity f)]
3754
- (if (.-cljs$lang$applyTo f)
3755
- (let [bc (bounded-count (inc fixed-arity) arglist)]
3756
- (if (<= bc fixed-arity)
3757
- (apply-to f bc arglist)
3758
- (.cljs$lang$applyTo f arglist)))
3759
- (.apply f f (to-array arglist)))))
3790
+ fixed-arity (.-cljs$lang$maxFixedArity f)
3791
+ bc (+ 2 (bounded-count (dec fixed-arity) args))]
3792
+ (if (<= bc fixed-arity)
3793
+ (apply-to f bc arglist)
3794
+ (.cljs$lang$applyTo f arglist)))
3795
+ (apply-to-simple f x y (seq args))))
3760
3796
([f x y z args]
3797
+ (if (.-cljs$lang$applyTo f)
3761
3798
(let [arglist (list* x y z args)
3762
- fixed-arity (.-cljs$lang$maxFixedArity f)]
3763
- (if (.-cljs$lang$applyTo f)
3764
- (let [bc (bounded-count (inc fixed-arity) arglist)]
3765
- (if (<= bc fixed-arity)
3766
- (apply-to f bc arglist)
3767
- (.cljs$lang$applyTo f arglist)))
3768
- (.apply f f (to-array arglist)))))
3799
+ fixed-arity (.-cljs$lang$maxFixedArity f)
3800
+ bc (+ 3 (bounded-count (- fixed-arity 2 ) args))]
3801
+ (if (<= bc fixed-arity)
3802
+ (apply-to f bc arglist)
3803
+ (.cljs$lang$applyTo f arglist)))
3804
+ (apply-to-simple f x y z (seq args))))
3769
3805
([f a b c d & args]
3770
- (let [arglist (cons a (cons b (cons c (cons d (spread args)))))
3771
- fixed-arity (.-cljs$lang$maxFixedArity f)]
3772
- (if (.-cljs$lang$applyTo f)
3773
- (let [bc (bounded-count (inc fixed-arity) arglist)]
3774
- (if (<= bc fixed-arity)
3775
- (apply-to f bc arglist)
3776
- (.cljs$lang$applyTo f arglist)))
3777
- (.apply f f (to-array arglist))))))
3806
+ (if (.-cljs$lang$applyTo f)
3807
+ (let [spread-args (spread args)
3808
+ arglist (cons a (cons b (cons c (cons d spread-args))))
3809
+ fixed-arity (.-cljs$lang$maxFixedArity f)
3810
+ bc (+ 4 (bounded-count (- fixed-arity 3 ) spread-args))]
3811
+ (if (<= bc fixed-arity)
3812
+ (apply-to f bc arglist)
3813
+ (.cljs$lang$applyTo f arglist)))
3814
+ (apply-to-simple f a b c d (spread args)))))
3815
+
3778
3816
(set! *unchecked-if* false )
3779
3817
3780
3818
(defn vary-meta
0 commit comments