Skip to content

Commit

Permalink
updated ordered-map constructor to use EMPTY_MAP
Browse files Browse the repository at this point in the history
  • Loading branch information
Paula Gearon committed May 23, 2023
1 parent b87ee8f commit 385469e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tiara/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
(putAll [m] (throw (UnsupportedOperationException.)))
(remove [k] (throw (UnsupportedOperationException.))))))

(def EMPTY_MAP (vec-map))

(defn vreverse
"Reverses a vector into a vector. Lists are reversed as usual."
[v]
Expand All @@ -94,7 +96,7 @@

(defn ordered-map
"Returns a map object that remembers the insertion order, similarly to a java.util.LinkedHashMap"
([] (vec-map))
([] EMPTY_MAP)
([& keyvals]
(let [kv-vec (vreverse
(second
Expand All @@ -106,5 +108,3 @@
kv-vec
(apply hash-map (interleave (map first kv-vec) (range)))))))

(def EMPTY_MAP (vec-map))

0 comments on commit 385469e

Please sign in to comment.