@@ -10022,7 +10022,7 @@ reduces them without incurring seq initialization"
10022
10022
10023
10023
(array? x)
10024
10024
(vec (map thisfn x))
10025
-
10025
+
10026
10026
(identical? (type x) js/Object)
10027
10027
(into {} (for [k (js-keys x)]
10028
10028
[(keyfn k) (thisfn (aget x k))]))
@@ -10235,20 +10235,23 @@ reduces them without incurring seq initialization"
10235
10235
(or (prefers* x y prefer-table) (isa? hierarchy x y)))
10236
10236
10237
10237
(defn- find-and-cache-best-method
10238
- [name dispatch-val hierarchy method-table prefer-table method-cache cached-hierarchy]
10238
+ [name dispatch-val hierarchy method-table prefer-table method-cache cached-hierarchy default-dispatch-val ]
10239
10239
(let [best-entry (reduce (fn [be [k _ :as e]]
10240
10240
(if (isa? @hierarchy dispatch-val k)
10241
10241
(let [be2 (if (or (nil? be) (dominates k (first be) prefer-table @hierarchy))
10242
10242
e
10243
10243
be)]
10244
10244
(when-not (dominates (first be2) k prefer-table @hierarchy)
10245
10245
(throw (js/Error.
10246
- (str " Multiple methods in multimethod '" name
10247
- " ' match dispatch value: " dispatch-val " -> " k
10248
- " and " (first be2) " , and neither is preferred" ))))
10246
+ (str " Multiple methods in multimethod '" name
10247
+ " ' match dispatch value: " dispatch-val " -> " k
10248
+ " and " (first be2) " , and neither is preferred" ))))
10249
10249
be2)
10250
10250
be))
10251
- nil @method-table)]
10251
+ nil @method-table)
10252
+ best-entry (if-let [entry (and (nil? best-entry) (@method-table default-dispatch-val ))]
10253
+ [default-dispatch-val entry]
10254
+ best-entry)]
10252
10255
(when best-entry
10253
10256
(if (= @cached-hierarchy @hierarchy)
10254
10257
(do
@@ -10257,7 +10260,7 @@ reduces them without incurring seq initialization"
10257
10260
(do
10258
10261
(reset-cache method-cache method-table cached-hierarchy hierarchy)
10259
10262
(find-and-cache-best-method name dispatch-val hierarchy method-table prefer-table
10260
- method-cache cached-hierarchy))))))
10263
+ method-cache cached-hierarchy default-dispatch-val ))))))
10261
10264
10262
10265
(defprotocol IMultiFn
10263
10266
(-reset [mf])
@@ -10432,10 +10435,8 @@ reduces them without incurring seq initialization"
10432
10435
(reset-cache method-cache method-table cached-hierarchy hierarchy))
10433
10436
(if-let [target-fn (@method-cache dispatch-val)]
10434
10437
target-fn
10435
- (if-let [target-fn (find-and-cache-best-method name dispatch-val hierarchy method-table
10436
- prefer-table method-cache cached-hierarchy)]
10437
- target-fn
10438
- (@method-table default-dispatch-val ))))
10438
+ (find-and-cache-best-method name dispatch-val hierarchy method-table
10439
+ prefer-table method-cache cached-hierarchy default-dispatch-val )))
10439
10440
10440
10441
(-prefer-method [mf dispatch-val-x dispatch-val-y]
10441
10442
(when (prefers* dispatch-val-x dispatch-val-y prefer-table)
@@ -10452,7 +10453,7 @@ reduces them without incurring seq initialization"
10452
10453
(-prefers [mf] @prefer-table)
10453
10454
(-default-dispatch-val [mf] default-dispatch-val )
10454
10455
(-dispatch-fn [mf] dispatch-fn)
10455
-
10456
+
10456
10457
INamed
10457
10458
(-name [this] (-name name))
10458
10459
(-namespace [this] (-namespace name))
0 commit comments