diff options
-rw-r--r-- | src/clojure/contrib/memoize.clj | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/clojure/contrib/memoize.clj b/src/clojure/contrib/memoize.clj index 558106c6..7becb30b 100644 --- a/src/clojure/contrib/memoize.clj +++ b/src/clojure/contrib/memoize.clj @@ -22,10 +22,9 @@ to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use." [function] - (let [cache (ref {})] + (let [cache (atom {})] (fn [& args] (or (@cache args) (let [result (apply function args)] - (dosync - (commute cache assoc args result)) + (swap! cache assoc args result) result))))) |