use reduce-kv to optimize ALL transform on maps, significant performance boost
This commit is contained in:
parent
2aff955a99
commit
6b7d18d874
2 changed files with 10 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
## 0.11.1 (unreleased)
|
## 0.11.1 (unreleased)
|
||||||
* More efficient inline caching for Clojure version, now inline caching is always within 5% of manually precompiled code
|
* More efficient inline caching for Clojure version, now inline caching is always within 5% of manually precompiled code
|
||||||
|
* Significant performance improvement for ALL transform on maps for Clojure version (25% on simple benchmarks)
|
||||||
|
|
||||||
## 0.11.0
|
## 0.11.0
|
||||||
* New `path` macro does intelligent inline caching of the provided path. The path is factored into a static portion and into params which may change on each usage of the path (e.g. local parameters). The static part is factored and compiled on the first run-through, and then re-used for all subsequent invocations. As an example, `[ALL (keypath k)]` is factored into `[ALL keypath]`, which is compiled and cached, and `[k]`, which is provided on each execution. If it is not possible to precompile the path (e.g. [ALL some-local-variable]), nothing is cached and the path will be compiled on each run-through.
|
* New `path` macro does intelligent inline caching of the provided path. The path is factored into a static portion and into params which may change on each usage of the path (e.g. local parameters). The static part is factored and compiled on the first run-through, and then re-used for all subsequent invocations. As an example, `[ALL (keypath k)]` is factored into `[ALL keypath]`, which is compiled and cached, and `[k]`, which is provided on each execution. If it is not possible to precompile the path (e.g. [ALL some-local-variable]), nothing is cached and the path will be compiled on each run-through.
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,15 @@
|
||||||
(doall (map next-fn structure))
|
(doall (map next-fn structure))
|
||||||
|
|
||||||
(map? structure)
|
(map? structure)
|
||||||
(->> structure (r/map vec) (r/map next-fn) (into empty-structure))
|
;; reduce-kv is much faster than doing r/map through call to (into ...)
|
||||||
|
(reduce-kv
|
||||||
|
(fn [m k v]
|
||||||
|
(let [[newk newv] (next-fn [k v])]
|
||||||
|
(assoc m newk newv)
|
||||||
|
))
|
||||||
|
empty-structure
|
||||||
|
structure
|
||||||
|
)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(->> structure (r/map next-fn) (into empty-structure))
|
(->> structure (r/map next-fn) (into empty-structure))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue