Optimize common case of listening to one derefable

This commit is contained in:
Dan Holmsand 2015-09-27 11:11:15 +02:00
parent 97194b6fca
commit 83b21167ea
1 changed files with 8 additions and 2 deletions

View File

@ -41,8 +41,14 @@
(when-some [obj *ratom-context*] (when-some [obj *ratom-context*]
(let [captured (.-cljsCaptured obj)] (let [captured (.-cljsCaptured obj)]
(set! (.-cljsCaptured obj) (set! (.-cljsCaptured obj)
(conj (if (nil? captured) #{} captured) (if (nil? captured)
derefable))))) (let [old (.-watching obj)]
(if (and (== 1 (count old))
(identical? derefable (first old)))
;; Optimize common case of one deref
old
#{derefable}))
(conj captured derefable))))))
(def reaction-counter 0) (def reaction-counter 0)