Permalink
Browse files

kvify now expands into a map-literal.

Will now return PersistentHashMap or PersistentArrayMap as
appropriate. Map-literals are emitted as calls to more efficient methods
than clojure.core/hash-map or clojure.core/array-map.
  • Loading branch information...
duelinmarkers committed Nov 18, 2014
1 parent 4830b16 commit d0a4bf16e8bf5a170ad869c13ef74b056c3694a8
Showing with 5 additions and 2 deletions.
  1. +3 −1 src/clojure/jry.clj
  2. +2 −1 test/expectations/jry_expectations.clj
@@ -95,4 +95,6 @@
m))))
(defmacro kvify [& xs]
`(hash-map ~@(interleave (map keyword xs) xs)))
(if (apply distinct? xs)
(zipmap (map keyword xs) xs)
(throw (RuntimeException. (str "duplicate keys to kvify: " xs)))))
@@ -62,5 +62,6 @@
(expect false ((k= :one 1 :two 2 :thr 3) {:one 1 :two 1 :thr 3 :x "x"}))
(expect false ((k= :one 1 :two 2 :thr 3) {:one 1 :two 2 :thr 1 :x "x"}))
(expect '(clojure.core/hash-map :a a :b b)
(expect '{:a a :b b}
(expanding (kvify a b)))
(expect RuntimeException (macroexpand-1 '(jry/kvify a a a a)))

0 comments on commit d0a4bf1

Please sign in to comment.