fixes issue #348: perf optimization during diffing algo to avoid calling addVNodes and removeVNodes when there is nothing to do.

pull/351/head
Caridy 7 years ago
parent 2271b7bdf1
commit b7f90368ee

@ -240,11 +240,13 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
} }
} }
} }
if (oldStartIdx > oldEndIdx) { if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
before = newCh[newEndIdx+1] == null ? null : newCh[newEndIdx+1].elm; if (oldStartIdx > oldEndIdx) {
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); before = newCh[newEndIdx+1] == null ? null : newCh[newEndIdx+1].elm;
} else if (newStartIdx > newEndIdx) { addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); } else {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
} }
} }

Loading…
Cancel
Save