Added identical? optimization to diffing.

This commit is contained in:
Aaron Craelius 2014-11-26 23:27:58 -05:00
parent e76ded09dd
commit 9211bc8955

View file

@ -586,10 +586,12 @@
nil))
cur-child)))
(defn- try-diff [parent vdom cur-dom-node top-level]
(defn- try-diff [parent spec vdom cur-dom-node top-level]
(let [cur-state (get-element-state cur-dom-node)
cur-tag (.-tag cur-state)
new-tag (first vdom)]
(if (identical? spec (.-element-spec cur-state))
cur-dom-node
(if (keyword-identical? new-tag cur-tag)
(do
;(println "diff hit" (first vdom))
@ -612,7 +614,7 @@
cur-dom-node))
(do
;(println "build hit" (first vdom) (first cur-vdom))
(replace-node-completely parent vdom cur-dom-node top-level)))))
(replace-node-completely parent vdom cur-dom-node top-level))))))
(declare bind-child)
@ -633,8 +635,8 @@
(if top-level
(do
;(println "starting diff replace")
(try-diff parent new-virtual-dom cur-dom-node top-level))
(try-diff parent new-virtual-dom cur-dom-node top-level))
(try-diff parent new-elem-spec new-virtual-dom cur-dom-node top-level))
(try-diff parent new-elem-spec new-virtual-dom cur-dom-node top-level))
(replace-node-completely
parent new-elem-spec cur-dom-node top-level)))))