Skip to content

Commit c312582

Browse files
committed
optimize
1 parent 1e754a9 commit c312582

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/malli/core.cljc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@
352352

353353
(defn -cached [s k f]
354354
(if (-cached? s)
355-
(-lookup-or-update-cache (-cache s) k #(f s))
355+
;; inlined (-lookup-or-update-cache (-cache s) k #(f s)) to avoid extra thunk
356+
(let [c (-cache s)]
357+
(or (@c k)
358+
(let [r (f s)]
359+
(swap! c assoc k r)
360+
r)))
356361
(f s)))
357362

358363
;;

0 commit comments

Comments
 (0)