Use defnav with regex* rather than defrichnav.
Nathan: vals is how collect / collect-one are implemented. You should use defnav rather than defrichnav since it handles that parameter in the background. defrichnav exists since the compiler doesn't do certain inlining optimizations, so defrichnav allows the handling of vals to be inlined manually. This is only important for navigators which do very little work (like keypath) – I think regexes are expensive enough that the inlining optimization won't be noticeable.
This commit is contained in:
parent
dc9e2205c3
commit
7dbe4dc524
1 changed files with 5 additions and 8 deletions
|
|
@ -622,15 +622,12 @@
|
|||
(do-keypath-transform vals structure key next-fn)
|
||||
))
|
||||
|
||||
(defrichnav ^{:doc "Navigates to the lazy sequence of successive matches when a regex is applied to a string, navigating to nil if it does not exist or nothing is found."}
|
||||
;; Setting the value to NONE will remove it from the collection.}
|
||||
regex*
|
||||
[re]
|
||||
(select* [this vals structure next-fn]
|
||||
(defnav regex* [re]
|
||||
(select* [this structure next-fn]
|
||||
(doseqres NONE [s (re-seq re structure)]
|
||||
(next-fn vals s)))
|
||||
#_(transform* [this vals structure next-fn]
|
||||
(next-fn (clojure.string/replace structure re vals))))
|
||||
(next-fn s)))
|
||||
(transform* [this structure next-fn]
|
||||
(clojure.string/replace structure re next-fn)))
|
||||
|
||||
(defrichnav
|
||||
^{:doc "Navigates to the key only if it exists in the map. Setting the value to NONE
|
||||
|
|
|
|||
Loading…
Reference in a new issue