expand optimized if-path to encompass any sequence of static functions
This commit is contained in:
parent
18e736e5d8
commit
f82ab31b36
3 changed files with 17 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
|||
* More efficient inline caching for Clojure version, now inline caching is always within 5% of manually precompiled code
|
||||
* Huge performance improvement for ALL transform on maps and vectors
|
||||
* Significant performance improvements for FIRST/LAST for vectors
|
||||
* Huge performance improvements for `if-path` and `cond-path`, especially for condition path containing a single static function
|
||||
* Huge performance improvements for `if-path` and `cond-path`, especially for condition path containing only static functions
|
||||
* Eliminated compiler warnings for ClojureScript version
|
||||
* Dropped support for Clojurescript below v1.7.10
|
||||
* Added :notpath metadata to signify pathedfn arguments that should be treated as regular arguments during inline factoring. If one of these arguments is not a static var reference or a non-collection value, the path will not factor.
|
||||
|
|
|
|||
|
|
@ -762,11 +762,14 @@
|
|||
path
|
||||
|
||||
(and (coll? path)
|
||||
(= 1 (count path))
|
||||
(fn? (first path)))
|
||||
(first path)
|
||||
(every? fn? path))
|
||||
(reduce
|
||||
(fn [combined afn]
|
||||
(fn [structure]
|
||||
(and (combined structure) (afn structure))
|
||||
))
|
||||
|
||||
path
|
||||
)))
|
||||
|
||||
(defn if-select [structure next-fn then-tester late-then late-else]
|
||||
(let [apath (if (then-tester structure)
|
||||
|
|
|
|||
|
|
@ -400,6 +400,14 @@
|
|||
(select k m))
|
||||
))))
|
||||
|
||||
(deftest optimized-if-path-test
|
||||
(is (= [-4 -2] (select [s/ALL (s/if-path [even? neg?] s/STAY)]
|
||||
[1 2 -3 -4 0 -2])))
|
||||
(is (= [1 2 -3 4 0 2] (transform [s/ALL (s/if-path [even? neg?] s/STAY)]
|
||||
-
|
||||
[1 2 -3 -4 0 -2])))
|
||||
)
|
||||
|
||||
(defspec multi-path-test
|
||||
(for-all+
|
||||
[k1 (limit-size 3 gen/keyword)
|
||||
|
|
|
|||
Loading…
Reference in a new issue