optimize selected? and not-selected?
This commit is contained in:
parent
f82ab31b36
commit
ff903cd236
3 changed files with 31 additions and 24 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
* 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
|
||||||
* Huge performance improvement for ALL transform on maps and vectors
|
* Huge performance improvement for ALL transform on maps and vectors
|
||||||
* Significant performance improvements for FIRST/LAST for vectors
|
* Significant performance improvements for FIRST/LAST for vectors
|
||||||
* Huge performance improvements for `if-path` and `cond-path`, especially for condition path containing only static functions
|
* Huge performance improvements for `if-path`, `cond-path`, `selected?`, and `not-selected?`, especially for condition path containing only static functions
|
||||||
* Eliminated compiler warnings for ClojureScript version
|
* Eliminated compiler warnings for ClojureScript version
|
||||||
* Dropped support for Clojurescript below v1.7.10
|
* 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.
|
* 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.
|
||||||
|
|
|
||||||
|
|
@ -363,30 +363,34 @@
|
||||||
will be parameterized in the order of which the parameterized navigators
|
will be parameterized in the order of which the parameterized navigators
|
||||||
were declared."
|
were declared."
|
||||||
[& path]
|
[& path]
|
||||||
(fixed-pathed-nav [late path]
|
(if-let [afn (i/extract-basic-filter-fn path)]
|
||||||
(select* [this structure next-fn]
|
afn
|
||||||
(i/filter-select
|
(fixed-pathed-nav [late path]
|
||||||
#(i/selected?* late %)
|
(select* [this structure next-fn]
|
||||||
structure
|
(i/filter-select
|
||||||
next-fn))
|
#(i/selected?* late %)
|
||||||
(transform* [this structure next-fn]
|
structure
|
||||||
(i/filter-transform
|
next-fn))
|
||||||
#(i/selected?* late %)
|
(transform* [this structure next-fn]
|
||||||
structure
|
(i/filter-transform
|
||||||
next-fn))))
|
#(i/selected?* late %)
|
||||||
|
structure
|
||||||
|
next-fn)))))
|
||||||
|
|
||||||
(defpathedfn not-selected? [& path]
|
(defpathedfn not-selected? [& path]
|
||||||
(fixed-pathed-nav [late path]
|
(if-let [afn (i/extract-basic-filter-fn path)]
|
||||||
(select* [this structure next-fn]
|
(fn [s] (not (afn s)))
|
||||||
(i/filter-select
|
(fixed-pathed-nav [late path]
|
||||||
#(i/not-selected?* late %)
|
(select* [this structure next-fn]
|
||||||
structure
|
(i/filter-select
|
||||||
next-fn))
|
#(i/not-selected?* late %)
|
||||||
(transform* [this structure next-fn]
|
structure
|
||||||
(i/filter-transform
|
next-fn))
|
||||||
#(i/not-selected?* late %)
|
(transform* [this structure next-fn]
|
||||||
structure
|
(i/filter-transform
|
||||||
next-fn))))
|
#(i/not-selected?* late %)
|
||||||
|
structure
|
||||||
|
next-fn)))))
|
||||||
|
|
||||||
(defpathedfn filterer
|
(defpathedfn filterer
|
||||||
"Navigates to a view of the current sequence that only contains elements that
|
"Navigates to a view of the current sequence that only contains elements that
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,10 @@
|
||||||
(setval [s/ALL (s/selected? s/ALL even?) s/END]
|
(setval [s/ALL (s/selected? s/ALL even?) s/END]
|
||||||
[:a]
|
[:a]
|
||||||
[[1 3 5] [2] [7 11 4 2] [10 1] []]
|
[[1 3 5] [2] [7 11 4 2] [10 1] []]
|
||||||
))))
|
)))
|
||||||
|
(is (= [2 4] (select [s/ALL (s/selected? even?)] [1 2 3 4])))
|
||||||
|
(is (= [1 3] (select [s/ALL (s/not-selected? even?)] [1 2 3 4])))
|
||||||
|
)
|
||||||
|
|
||||||
(defspec identity-test
|
(defspec identity-test
|
||||||
(for-all+
|
(for-all+
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue