caching-hash

macroadded v1.9.494removed v1.9.493added v0.0-1211Edit
(caching-hash coll hash-fn hash-key)

Source code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro caching-hash [coll hash-fn hash-key]
  (core/assert (clojure.core/symbol? hash-key) "hash-key is substituted twice")
  `(let [h# ~hash-key]
     (if-not (nil? h#)
       h#
       (let [h# (~hash-fn ~coll)]
         (set! ~hash-key h#)
         h#))))