huge speedup to if-path by having specialized implementation separate from cond-path
This commit is contained in:
parent
59423c358e
commit
ff2853381c
2 changed files with 29 additions and 3 deletions
|
|
@ -528,9 +528,21 @@
|
|||
|
||||
(defpathedfn if-path
|
||||
"Like cond-path, but with if semantics."
|
||||
([cond-p if-path] (cond-path cond-p if-path))
|
||||
([cond-p if-path else-path]
|
||||
(cond-path cond-p if-path nil else-path)))
|
||||
([cond-p then-path]
|
||||
(fixed-pathed-nav [late-cond cond-p
|
||||
late-then then-path]
|
||||
(select* [this structure next-fn]
|
||||
(i/if-select structure next-fn late-cond late-then STOP))
|
||||
(transform* [this structure next-fn]
|
||||
(i/if-transform structure next-fn late-cond late-then STOP))))
|
||||
([cond-p then-path else-path]
|
||||
(fixed-pathed-nav [late-cond cond-p
|
||||
late-then then-path
|
||||
late-else else-path]
|
||||
(select* [this structure next-fn]
|
||||
(i/if-select structure next-fn late-cond late-then late-else))
|
||||
(transform* [this structure next-fn]
|
||||
(i/if-transform structure next-fn late-cond late-then late-else)))))
|
||||
|
||||
(defpathedfn multi-path
|
||||
"A path that branches on multiple paths. For updates,
|
||||
|
|
|
|||
|
|
@ -709,6 +709,20 @@
|
|||
res
|
||||
))))))
|
||||
|
||||
(defn if-select [structure next-fn late-cond late-then late-else]
|
||||
(let [apath (if (empty? (compiled-select* late-cond structure))
|
||||
late-else
|
||||
late-then)]
|
||||
(doall (mapcat next-fn (compiled-select* apath structure)))
|
||||
))
|
||||
|
||||
(defn if-transform [structure next-fn late-cond late-then late-else]
|
||||
(let [apath (if (empty? (compiled-select* late-cond structure))
|
||||
late-else
|
||||
late-then)]
|
||||
(compiled-transform* apath next-fn structure)
|
||||
))
|
||||
|
||||
(defn filter-select [afn structure next-fn]
|
||||
(if (afn structure)
|
||||
(next-fn structure)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue