对clojure.set/map-invert的两次性能提升
1) 使用reduce-kv避免从输入map实例化mapentry
2) 使用transients创建输出map
*性能:*
(use 'criterium.core)
(require '[clojure.set :as set])
(def m1 (zipmap (range 1) (range 1)))
(def m10 (zipmap (range 10) (range 10)))
(def m100 (zipmap (range 100) (range 100)))
(def m1000 (zipmap (range 1000) (range 1000)))
(quick-bench (set/map-invert m1000))
(quick-bench (set/map-invert m100))
(quick-bench (set/map-invert m10))
(quick-bench (set/map-invert m1))
;; before: 138 ns 1.8 µs 20.6 µs 304 µs
;; after: 151 ns 1.3 µs 9.0 µs 126 µs
*补丁:* clj-1808-map-invert-should-use-reduce-kv-and-transient.patch
*审阅者:* Alex Miller