From 2fcef44f5970811d807d3085fbf4ac3e6e1fffe8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Marczyk?= <michal.marczyk@gmail.com>
Date: Wed, 30 May 2012 09:44:43 +0200
Subject: [PATCH] Use transient map in zipmap

---
 src/clj/clojure/core.clj |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index e05a263..8b9dc69 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -2652,7 +2652,7 @@
 
 
 
-(defn zipmap
+#_(defn zipmap
   "Returns a map with the keys mapped to the corresponding vals."
   {:added "1.0"
    :static true}
@@ -5833,6 +5833,19 @@
      ([a b c] (f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c)))
      ([a b c & ds] (apply f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c) ds)))))
 
+(defn zipmap
+  "Returns a map with the keys mapped to the corresponding vals."
+  {:added "1.0"
+   :static true}
+  [keys vals]
+    (loop [map (transient {})
+           ks (seq keys)
+           vs (seq vals)]
+      (if (and ks vs)
+        (recur (assoc! map (first ks) (first vs))
+               (next ks)
+               (next vs))
+        (persistent! map))))
 
 ;;;;;;; case ;;;;;;;;;;;;;
 (defn- shift-mask [shift mask x]
-- 
1.7.1

