Skip to content

Commit

Permalink
Merge pull request #701 from bsless/fix-interface-maps
Browse files Browse the repository at this point in the history
Add dispatch for every implementation of IPersistentMap
  • Loading branch information
ikitommi authored Sep 30, 2024
2 parents e2c63d6 + c96b22b commit d11deb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/reitit-core/src/reitit/walk.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[m k v]
(assoc! m (if (string? k) (keyword k) (-keywordize k)) (-keywordize v)))

(defn- -keywordize-map
(defn- -keywordize-kvreducible
[m]
(persistent! (reduce-kv keywordize-kv (transient (empty m)) m)))

Expand All @@ -29,6 +29,14 @@
(doseq [type [clojure.lang.PersistentArrayMap
clojure.lang.PersistentHashMap
clojure.lang.PersistentTreeMap]]
(extend type IKeywordize {:-keywordize -keywordize-kvreducible}))

(defn- -keywordize-map
[m]
(let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
(into {} (map f) m)))

(doseq [type [clojure.lang.IPersistentMap]]
(extend type IKeywordize {:-keywordize -keywordize-map}))

(extend-protocol IKeywordize
Expand Down

0 comments on commit d11deb3

Please sign in to comment.