diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index 8bd36e5..27c3708 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -619,8 +619,8 @@ ([cond-p then-path] (if-path cond-p then-path STOP)) ([cond-p then-path else-path] - (let [then-comp (i/comp-paths* then-path) - else-comp (i/comp-paths* else-path) + (let [then-comp (i/comp-paths-internalized then-path) + else-comp (i/comp-paths-internalized else-path) then-needed (i/num-needed-params then-comp) else-needed (i/num-needed-params else-comp) then-nav (i/extract-rich-nav then-comp) @@ -651,7 +651,7 @@ then-needed else-nav )))) - (let [cond-comp (i/comp-paths* cond-p) + (let [cond-comp (i/comp-paths-internalized cond-p) cond-needed (i/num-needed-params cond-comp)] (richnav (+ then-needed else-needed cond-needed) (select* [this params params-idx vals structure next-fn] @@ -706,8 +706,8 @@ ([] STAY) ([path] (i/comp-paths* path)) ([path1 path2] - (let [comp1 (i/comp-paths* path1) - comp2 (i/comp-paths* path2) + (let [comp1 (i/comp-paths-internalized path1) + comp2 (i/comp-paths-internalized path2) comp1-needed (i/num-needed-params comp1) nav1 (i/extract-rich-nav comp1) nav2 (i/extract-rich-nav comp2) diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index 2be4812..0742310 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -389,6 +389,9 @@ (next-fn params2 params-idx2 vals-next structure-next) ))))))))) +(defn comp-paths-internalized [path] + (capture-params-internally (comp-paths* path))) + (extend-protocol PathComposer nil (do-comp-paths [o] diff --git a/src/clj/com/rpl/specter/macros.clj b/src/clj/com/rpl/specter/macros.clj index 12bf1c0..5e6c323 100644 --- a/src/clj/com/rpl/specter/macros.clj +++ b/src/clj/com/rpl/specter/macros.clj @@ -67,16 +67,19 @@ (+ ~PARAMS-IDX-SYM ~num-params) (conj vals# c#) ~structure-sym) - ))] - (i/->ParamsNeededPath - (reify RichNavigator - (~'rich-select* [this# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#] - (collector# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#)) - (~'rich-transform* [this# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#] - (collector# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#)) - ) - ~num-params - ))) + )) + nav# (reify RichNavigator + (~'rich-select* [this# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#] + (collector# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#)) + (~'rich-transform* [this# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#] + (collector# ~PARAMS-SYM ~PARAMS-IDX-SYM vals# ~structure-sym next-fn#)) + )] + (if (= ~num-params 0) + (i/no-params-rich-compiled-path nav#) + (i/->ParamsNeededPath + nav# + ~num-params + )))) (defn ^:no-doc pathed-nav* [builder paths-seq latefns-sym pre-bindings post-bindings impls] (let [num-params-sym (gensym "num-params")] @@ -102,7 +105,9 @@ ret# ~(builder post-bindings num-params-sym impls) ] (if (not any-params-needed?#) - (i/bind-params* ret# nil 0) + (if (i/params-needed-path? ret#) + (i/bind-params* ret# nil 0) + ret#) ret# ))))