From 59423c358e6d8c4f38fd3d684d1cb054c6100b2b Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Sat, 4 Jun 2016 14:51:26 -0400 Subject: [PATCH] huge speedup for cond-path --- src/clj/com/rpl/specter/impl.cljx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index da194a9..02f63a3 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -696,15 +696,18 @@ )) (defn retrieve-cond-selector [cond-paths structure] - (->> cond-paths - (partition 2) - (drop-while (fn [[c-selector _]] - (->> structure - (compiled-select* c-selector) - empty?))) - first - second - )) + (let [aseq (seq cond-paths)] + (if aseq + (loop [s aseq] + (let [tester (first s) + s2 (next s) + res (first s2)] + (if (empty? (compiled-select* tester structure)) + (let [s3 (next s2)] + (if s3 (recur s3)) + ) + res + )))))) (defn filter-select [afn structure next-fn] (if (afn structure)