Fixed merged cnflicts

This commit is contained in:
Pietro F. Menna 2015-06-24 11:49:27 -04:00
commit 67d95ee00a
4 changed files with 29 additions and 18 deletions

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.5.4

View file

@ -1,4 +1,6 @@
(defproject com.rpl/specter "0.5.4"
(def VERSION (.trim (slurp "VERSION")))
(defproject com.rpl/specter VERSION
:dependencies [[org.clojure/clojure "1.6.0"]
]
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"] ; this prevents JVM from doing optimizations which can remove stack traces from NPE and other exceptions

View file

@ -129,7 +129,7 @@
(defn codewalker [afn] (->CodeWalkerStructurePath afn))
(defn filterer [afn] (->FilterStructurePath afn))
(defn filterer [& path] (->FilterStructurePath (comp-paths* path)))
(defn keypath [akey] (->KeyPath akey))

View file

@ -301,6 +301,25 @@
(defn- conj-all! [cell elems]
(set-cell! cell (concat (get-cell cell) elems)))
(defn compiled-select*
[^com.rpl.specter.impl.TransformFunctions tfns structure]
(let [^com.rpl.specter.impl.ExecutorFunctions ex (.executors tfns)]
((.select-executor ex) (.selector tfns) structure)
))
(defn compiled-transform*
[^com.rpl.specter.impl.TransformFunctions tfns transform-fn structure]
(let [^com.rpl.specter.impl.ExecutorFunctions ex (.executors tfns)]
((.transform-executor ex) (.transformer tfns) transform-fn structure)
))
(defn selected?*
[compiled-path structure]
(->> structure
(compiled-select* compiled-path)
empty?
not))
;; returns vector of all results
(defn- walk-select [pred continue-fn structure]
(let [ret (mutable-cell [])
@ -313,12 +332,12 @@
(get-cell ret)
))
(defn- filter+ancestry [afn aseq]
(defn- filter+ancestry [path aseq]
(let [aseq (vec aseq)]
(reduce (fn [[s m :as orig] i]
(let [e (get aseq i)
pos (count s)]
(if (afn e)
(if (selected?* path e)
[(conj s e) (assoc m pos i)]
orig
)))
@ -391,14 +410,14 @@
(codewalk-until (.afn this) next-fn structure)))
(deftype FilterStructurePath [afn])
(deftype FilterStructurePath [path])
(extend-protocol StructurePath
FilterStructurePath
(select* [^FilterStructurePath this structure next-fn]
(->> structure (filter (.afn this)) doall next-fn))
(->> structure (filter #(selected?* (.path this) %)) doall next-fn))
(transform* [^FilterStructurePath this structure next-fn]
(let [[filtered ancestry] (filter+ancestry (.afn this) structure)
(let [[filtered ancestry] (filter+ancestry (.path this) structure)
;; the vec is necessary so that we can get by index later
;; (can't get by index for cons'd lists)
next (vec (next-fn filtered))]
@ -473,17 +492,6 @@
(next-fn structure)
))
(defn compiled-select*
[^com.rpl.specter.impl.TransformFunctions tfns structure]
(let [^com.rpl.specter.impl.ExecutorFunctions ex (.executors tfns)]
((.select-executor ex) (.selector tfns) structure)
))
(defn compiled-transform*
[^com.rpl.specter.impl.TransformFunctions tfns transform-fn structure]
(let [^com.rpl.specter.impl.ExecutorFunctions ex (.executors tfns)]
((.transform-executor ex) (.transformer tfns) transform-fn structure)
))
(deftype ConditionalPath [cond-pairs])