@nathanmarz: thanks for the tip, changing to vtransformed
brings it down to 163.9 µs. The implementation code is beyond me at the moment, so I simply created the following in my namespace:
(s/defdynamicnav vtransformed
"Navigates to a view of the current value by transforming it with the
specified path and update-fn."
[path update-fn]
(s/late-bound-nav [late (s/late-path path)
late-fn update-fn]
(select* [this structure next-fn]
(next-fn (s/compiled-vtransform late late-fn structure)))
(transform* [this structure next-fn]
(next-fn (s/compiled-vtransform late late-fn structure)))))
Results are correct across all versions of the parser. Latest parser looks like this:
(s/select [s/ALL :systems s/ALL :containers s/ALL
(vtransformed [(s/collect-one :name) :dependencies s/ALL]
(fn [[c] d]
{:container c
:dependency (:name d)
:transports (:transport d)
:entities (:data_entity d '())}))
:dependencies s/ALL]
yaml-data)
@h0bbit looking at it again it looks like you actually want a version of view
that lets you look at collected values at the same time
then you could write:
(s/select [s/ALL :systems s/ALL :containers s/ALL
(s/collect-one :name) :dependencies s/ALL
(my-view
(fn [[c] d]
{:container c
:dependency (:name d)
:transports (:transport d)
:entities (:data_entity d '())}
))]
yaml-data)
my-view
would be:
(defrichnav my-view
[afn]
(select* [this vals structure next-fn]
(next-fn [] (afn vals structure)))
(transform* [this vals structure next-fn]
(next-fn [] (afn vals structure))))
seems like that should be much faster
@nathanmarz: wow, that brought it down to 87.3 µs. Thanks. I have loads to learn and think about with this library!
I’ll study some more to get a better understanding of views and when to use them