Cleanup arguments

This commit is contained in:
Tommi Reiman 2017-11-07 22:56:58 +02:00
parent c378d0b5af
commit 0d63aa1d43

View file

@ -31,12 +31,12 @@
(update-segment [this subs lcs]) (update-segment [this subs lcs])
(set-data [this data]) (set-data [this data])
(add-child [this key child]) (add-child [this key child])
(insert-child [this key path-spec o])) (insert-child [this key path-spec data]))
(extend-protocol Node (extend-protocol Node
nil nil
(lookup [_ _ _]) (lookup [_ _ _])
(get-segment [this])) (get-segment [_]))
(defrecord Match [data params]) (defrecord Match [data params])
@ -46,7 +46,7 @@
children' (impl/fast-map children)] children' (impl/fast-map children)]
(reify (reify
Node Node
(lookup [this path params] (lookup [_ path params]
(let [i (.indexOf ^String path "/")] (let [i (.indexOf ^String path "/")]
(if (pos? i) (if (pos? i)
(let [value (subs path 0 i)] (let [value (subs path 0 i)]
@ -57,21 +57,21 @@
(lookup ?wild path' params) (lookup ?wild path' params)
(lookup ?catch path' params)))) (lookup ?catch path' params))))
(->Match data (assoc params param path))))) (->Match data (assoc params param path)))))
(get-segment [this] (get-segment [_]
segment) segment)
(set-data [this data] (set-data [_ data]
(wild-node segment param children data)) (wild-node segment param children data))
(add-child [this key child] (add-child [_ key child]
(wild-node segment param (assoc children key child) data)) (wild-node segment param (assoc children key child) data))
(insert-child [this key path-spec o] (insert-child [_ key path-spec child-data]
(wild-node segment param (update children key insert path-spec o) data))))) (wild-node segment param (update children key insert path-spec child-data) data)))))
(defn catch-all-node [segment children param data] (defn catch-all-node [segment children param data]
(reify (reify
Node Node
(lookup [this path params] (lookup [_ path params]
(->Match data (assoc params param path))) (->Match data (assoc params param path)))
(get-segment [this] (get-segment [_]
segment))) segment)))
(defn static-node [^String segment children data] (defn static-node [^String segment children data]
@ -81,7 +81,7 @@
children' (impl/fast-map children)] children' (impl/fast-map children)]
(reify (reify
Node Node
(lookup [this path params] (lookup [_ path params]
(if (.equals segment path) (if (.equals segment path)
(->Match data params) (->Match data params)
(let [p (if (>= (count path) size) (subs path 0 size))] (let [p (if (>= (count path) size) (subs path 0 size))]
@ -91,15 +91,15 @@
(or (lookup child path params) (or (lookup child path params)
(lookup ?wild path params) (lookup ?wild path params)
(lookup ?catch path params))))))) (lookup ?catch path params)))))))
(get-segment [this] (get-segment [_]
segment) segment)
(update-segment [this subs lcs] (update-segment [_ subs lcs]
(static-node (subs segment lcs) children data)) (static-node (subs segment lcs) children data))
(set-data [this data] (set-data [_ data]
(static-node segment children data)) (static-node segment children data))
(add-child [this key child] (add-child [_ key child]
(static-node segment (assoc children key child) data)) (static-node segment (assoc children key child) data))
(insert-child [this key path-spec child-data] (insert-child [_ key path-spec child-data]
(static-node segment (update children key insert path-spec child-data) data))))) (static-node segment (update children key insert path-spec child-data) data)))))
(defn- wild? [s] (defn- wild? [s]