[render/render] Misc comment fixes

This commit is contained in:
Pierre-Yves Gérardy 2018-04-23 11:37:24 +02:00 committed by Pierre-Yves Gérardy
parent f7a95d8c12
commit 44e165a357

View file

@ -187,10 +187,8 @@ module.exports = function($window) {
// //
// The updateNodes() function: // The updateNodes() function:
// - deals with trivial cases // - deals with trivial cases
// - determines whether the lists are keyed or unkeyed // - determines whether the lists are keyed or unkeyed based on the first non-null node
// (Currently we look for the first pair of non-null nodes and deem the lists unkeyed // of each list.
// if both nodes are unkeyed. TODO (v2) We may later take advantage of the fact that
// mixed diff is not supported and settle on the keyedness of the first vnode we find)
// - diffs them and patches the DOM if needed (that's the brunt of the code) // - diffs them and patches the DOM if needed (that's the brunt of the code)
// - manages the leftovers: after diffing, are there: // - manages the leftovers: after diffing, are there:
// - old nodes left to remove? // - old nodes left to remove?
@ -265,7 +263,7 @@ module.exports = function($window) {
else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns) else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)
else if (vnodes == null) removeNodes(old, 0, old.length) else if (vnodes == null) removeNodes(old, 0, old.length)
else { else {
// default to keyed because, when either list isfull of null nodes, it has fewer branches // default to keyed because, when either list is full of null nodes, it has fewer branches
var start = 0, oldStart = 0, isOldKeyed = true, isKeyed = true var start = 0, oldStart = 0, isOldKeyed = true, isKeyed = true
for (; oldStart < old.length; oldStart++) { for (; oldStart < old.length; oldStart++) {
if (old[oldStart] != null) { if (old[oldStart] != null) {
@ -288,9 +286,8 @@ module.exports = function($window) {
// Don't index past the end of either list (causes deopts). // Don't index past the end of either list (causes deopts).
var commonLength = old.length < vnodes.length ? old.length : vnodes.length var commonLength = old.length < vnodes.length ? old.length : vnodes.length
// Rewind if necessary to the first non-null index on either side. // Rewind if necessary to the first non-null index on either side.
// We could also either create or remove nodes when start !== oldStart // We could alternatively either explicitly create or remove nodes when `start !== oldStart`
// but that would be optimizing for sparse lists which are more rare // but that would be optimizing for sparse lists which are more rare than dense ones.
// than dense ones.
start = start < oldStart ? start : oldStart start = start < oldStart ? start : oldStart
for (; start < commonLength; start++) { for (; start < commonLength; start++) {
o = old[start] o = old[start]
@ -308,7 +305,7 @@ module.exports = function($window) {
var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v
while (oldEnd >= oldStart && end >= start) { while (oldEnd >= oldStart && end >= start) {
// both top down // both top-down
o = old[oldStart] o = old[oldStart]
v = vnodes[start] v = vnodes[start]
if (o == null) oldStart++ if (o == null) oldStart++