                  (recur (inc i))
                  false))))))
 
+(defn- ^boolean in-arr [a x]
+  (not (or (nil? a)
+           (== -1 (.indexOf a x)))))
+
 (defn- in-context [obj f]
   (binding [*ratom-context* obj]
     (f)))
 
 (defn- deref-capture [f r]
-  (let [watch (.-watching r)]
-    (set! (.-captured r) nil)
-    (when (dev?)
-      (set! (.-ratomGeneration r)
-            (set! generation (inc generation))))
-    (let [res (in-context r f)
-          capt (.-captured r)]
-      (set! (.-dirty? r) false)
-      (when-not (arr-eq capt watch)
-        (._update-watching r capt))
-      res)))
+  (set! (.-captured r) nil)
+  (when (dev?)
+    (set! (.-ratomGeneration r)
+          (set! generation (inc generation))))
+  (let [res (in-context r f)
+        c (.-captured r)]
+    (set! (.-dirty? r) false)
+    (when-not (arr-eq c (.-watching r))
+      (._update-watching r c))
+    res))
 
 (defn- notify-deref-watcher! [derefable]
   (when-some [r *ratom-context*]
     (let [c (.-captured r)]
       (if (nil? c)
         (set! (.-captured r) (array derefable))
-        (when (== -1 (.indexOf c derefable))
+        (when-not (in-arr c derefable)
           (.push c derefable))))))
 
 (defn- check-watches [old new]

          (let [k (aget a i)
                f (aget a (inc i))]
            (f k this old new))
          (recur (+ 2 i))))))
  nil)

(defn- pr-atom [a writer opts s]
  (-write writer (str "#<" s " "))

          wg watching]
      (set! watching der)
      (doseq [w der]
        (when-not (in-arr wg w) 
          (-add-watch w this handle-reaction-change)))
      (doseq [w wg]
        (when-not (in-arr der w)
          (-remove-watch w this))))
    nil)

