Skip to content

Commit 8283993

Browse files
committed
没有递归
1 parent ade952b commit 8283993

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/reconcile.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ const diff = (aCh, bCh) => {
177177
bHead = 0,
178178
aTail = aCh.length - 1,
179179
bTail = bCh.length - 1,
180-
aMap = null,
181-
bMap = null,
180+
aMap = {},
181+
bMap = {},
182182
same = (a, b) => a.key != null && b.key != null && a.key === b.key,
183183
temp = [],
184184
actions = []
@@ -206,18 +206,13 @@ const diff = (aCh, bCh) => {
206206
aHead++
207207
bHead++
208208
}
209-
if (!aMap) {
210-
aMap = {}
211-
for (let i = aHead; i <= aTail; i++) {
212-
aMap[aCh[i].key] = i
213-
}
209+
for (let i = aHead; i <= aTail; i++) {
210+
aMap[aCh[i].key] = i
214211
}
215-
if (!bMap) {
216-
bMap = {}
217-
for (let i = bHead; i <= bTail; i++) {
218-
bMap[bCh[i].key] = i
219-
}
212+
for (let i = bHead; i <= bTail; i++) {
213+
bMap[bCh[i].key] = i
220214
}
215+
221216
while (aHead <= aTail || bHead <= bTail) {
222217
var aElm = aCh[aHead],
223218
bElm = bCh[bHead]

0 commit comments

Comments
 (0)