Skip to content

Commit 7179aca

Browse files
committed
[refactor]updateNodes: Adjust variable declaration positions and names.
These changes aim to improve code readability and slightly reduce the bundle size.
1 parent f018fa5 commit 7179aca

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

render/render.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ module.exports = function() {
274274
else {
275275
var isOldKeyed = old[0] != null && old[0].key != null
276276
var isKeyed = vnodes[0] != null && vnodes[0].key != null
277-
var start = 0, oldStart = 0
277+
var start = 0, oldStart = 0, o, v
278278
if (isOldKeyed !== isKeyed) {
279279
removeNodes(parent, old, 0, old.length)
280280
createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)
@@ -299,7 +299,7 @@ module.exports = function() {
299299
if (vnodes.length > commonLength) createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)
300300
} else {
301301
// keyed diff
302-
var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v, oe, ve, topSibling
302+
var oldEnd = old.length - 1, end = vnodes.length - 1, oe, ve, topSibling
303303

304304
// bottom-up
305305
while (oldEnd >= oldStart && end >= start) {
@@ -347,11 +347,12 @@ module.exports = function() {
347347
else if (oldStart > oldEnd) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)
348348
else {
349349
// inspired by ivi https://github.com/ivijs/ivi/ by Boris Kaul
350-
var originalNextSibling = nextSibling, vnodesLength = end - start + 1, oldIndices = new Array(vnodesLength), li=0, i=0, pos = 2147483647, matched = 0, map, lisIndices
351-
for (i = 0; i < vnodesLength; i++) oldIndices[i] = -1
350+
var originalNextSibling = nextSibling, pos = 2147483647, matched = 0
351+
var oldIndices = new Array(end - start + 1)
352+
for (var i = 0; i < oldIndices.length; i++) oldIndices[i] = -1
352353
var map = Object.create(null)
353354
for (var i = start; i <= end; i++) map[vnodes[i].key] = i
354-
for (i = oldEnd; i >= oldStart; i--) {
355+
for (var i = oldEnd; i >= oldStart; i--) {
355356
oe = old[i]
356357
var newIndex = map[oe.key]
357358
if (newIndex != null) {
@@ -371,22 +372,22 @@ module.exports = function() {
371372
if (pos === -1) {
372373
// the indices of the indices of the items that are part of the
373374
// longest increasing subsequence in the oldIndices list
374-
lisIndices = makeLisIndices(oldIndices)
375-
li = lisIndices.length - 1
376-
for (i = end; i >= start; i--) {
377-
v = vnodes[i]
378-
if (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)
375+
var lisIndices = makeLisIndices(oldIndices)
376+
var li = lisIndices.length - 1
377+
for (var i = end; i >= start; i--) {
378+
ve = vnodes[i]
379+
if (oldIndices[i-start] === -1) createNode(parent, ve, hooks, ns, nextSibling)
379380
else {
380381
if (lisIndices[li] === i - start) li--
381-
else moveDOM(parent, v, nextSibling)
382+
else moveDOM(parent, ve, nextSibling)
382383
}
383-
if (v.dom != null) nextSibling = vnodes[i].dom
384+
if (ve.dom != null) nextSibling = ve.dom
384385
}
385386
} else {
386-
for (i = end; i >= start; i--) {
387-
v = vnodes[i]
388-
if (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)
389-
if (v.dom != null) nextSibling = vnodes[i].dom
387+
for (var i = end; i >= start; i--) {
388+
ve = vnodes[i]
389+
if (oldIndices[i-start] === -1) createNode(parent, ve, hooks, ns, nextSibling)
390+
if (ve.dom != null) nextSibling = ve.dom
390391
}
391392
}
392393
}
@@ -487,7 +488,7 @@ module.exports = function() {
487488
var u = 0, v = 0, i = 0
488489
var il = lisTemp.length = a.length
489490
for (var i = 0; i < il; i++) lisTemp[i] = a[i]
490-
for (var i = 0; i < il; ++i) {
491+
for (var i = 0; i < il; i++) {
491492
if (a[i] === -1) continue
492493
var j = result[result.length - 1]
493494
if (a[j] < a[i]) {

0 commit comments

Comments
 (0)