Skip to content

Commit 145eed4

Browse files
committed
tmp-revert
1 parent bad9182 commit 145eed4

File tree

1 file changed

+59
-40
lines changed

1 file changed

+59
-40
lines changed

packages/reactivity/src/system.ts

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -258,68 +258,87 @@ function linkNewDep(
258258
return newLink
259259
}
260260

261-
function checkDirty(current: Link): boolean {
262-
let prevLinks: OneWayLink<Link> | undefined
263-
let checkDepth = 0
261+
function checkDirty(link: Link): boolean {
262+
let stack = 0
263+
let dirty: boolean
264264

265265
top: do {
266-
const dep = current.dep
266+
dirty = false
267+
const dep = link.dep
267268

268269
if ('flags' in dep) {
269270
const depFlags = dep.flags
270271
if (
271272
(depFlags & (SubscriberFlags.Computed | SubscriberFlags.Dirty)) ===
272273
(SubscriberFlags.Computed | SubscriberFlags.Dirty)
273274
) {
274-
if (dep.update()) {
275-
if (current.nextSub !== undefined || current.prevSub !== undefined) {
276-
shallowPropagate(dep.subs!)
275+
if ((dep as Computed).update()) {
276+
const subs = dep.subs!
277+
if (subs.nextSub !== undefined) {
278+
shallowPropagate(subs)
277279
}
278-
while (checkDepth--) {
279-
const computed = current.sub as Computed
280-
const firstSub = computed.subs!
281-
282-
if (computed.update()) {
283-
if (firstSub.nextSub !== undefined) {
284-
shallowPropagate(firstSub)
285-
current = prevLinks!.target
286-
prevLinks = prevLinks!.linked
287-
} else {
288-
current = firstSub
289-
}
290-
continue
291-
}
292-
293-
if (firstSub.nextSub !== undefined) {
294-
if ((current = prevLinks!.target.nextDep!) === undefined) {
295-
return false
296-
}
297-
prevLinks = prevLinks!.linked
298-
continue top
299-
}
300-
301-
return false
302-
}
303-
return true
280+
dirty = true
304281
}
305282
} else if (
306283
(depFlags &
307284
(SubscriberFlags.Computed | SubscriberFlags.PendingComputed)) ===
308285
(SubscriberFlags.Computed | SubscriberFlags.PendingComputed)
309286
) {
310-
dep.flags = depFlags & ~SubscriberFlags.PendingComputed
311-
if (current.nextSub !== undefined || current.prevSub !== undefined) {
312-
prevLinks = { target: current, linked: prevLinks }
287+
const depSubs = dep.subs!
288+
if (depSubs.nextSub !== undefined) {
289+
depSubs.prevSub = link
313290
}
314-
++checkDepth
315-
current = dep.deps!
291+
link = dep.deps!
292+
++stack
316293
continue
317294
}
318295
}
319296

320-
if ((current = current.nextDep!) === undefined) {
321-
return false
297+
if (!dirty && link.nextDep !== undefined) {
298+
link = link.nextDep
299+
continue
300+
}
301+
302+
if (stack) {
303+
let sub = link.sub as Computed
304+
do {
305+
--stack
306+
const subSubs = sub.subs!
307+
308+
if (dirty) {
309+
if (sub.update()) {
310+
if ((link = subSubs.prevSub!) !== undefined) {
311+
subSubs.prevSub = undefined
312+
shallowPropagate(subSubs)
313+
sub = link.sub as Computed
314+
} else {
315+
sub = subSubs.sub as Computed
316+
}
317+
continue
318+
}
319+
} else {
320+
sub.flags &= ~SubscriberFlags.PendingComputed
321+
}
322+
323+
if ((link = subSubs.prevSub!) !== undefined) {
324+
subSubs.prevSub = undefined
325+
if (link.nextDep !== undefined) {
326+
link = link.nextDep
327+
continue top
328+
}
329+
sub = link.sub as Computed
330+
} else {
331+
if ((link = subSubs.nextDep!) !== undefined) {
332+
continue top
333+
}
334+
sub = subSubs.sub as Computed
335+
}
336+
337+
dirty = false
338+
} while (stack)
322339
}
340+
341+
return dirty
323342
} while (true)
324343
}
325344

0 commit comments

Comments
 (0)