Skip to content

Commit 7ff23b0

Browse files
committed
tmp-revert
1 parent a0120c6 commit 7ff23b0

File tree

1 file changed

+59
-40
lines changed

1 file changed

+59
-40
lines changed

packages/reactivity/src/system.ts

+59-40
Original file line numberDiff line numberDiff line change
@@ -252,68 +252,87 @@ function linkNewDep(
252252
return newLink
253253
}
254254

255-
function checkDirty(current: Link): boolean {
256-
let prevLinks: OneWayLink<Link> | undefined
257-
let checkDepth = 0
255+
function checkDirty(link: Link): boolean {
256+
let stack = 0
257+
let dirty: boolean
258258

259259
top: do {
260-
const dep = current.dep
260+
dirty = false
261+
const dep = link.dep
261262

262263
if ('flags' in dep) {
263264
const depFlags = dep.flags
264265
if (
265266
(depFlags & (SubscriberFlags.Computed | SubscriberFlags.Dirty)) ===
266267
(SubscriberFlags.Computed | SubscriberFlags.Dirty)
267268
) {
268-
if (dep.update()) {
269-
if (current.nextSub !== undefined || current.prevSub !== undefined) {
270-
shallowPropagate(dep.subs!)
269+
if ((dep as Computed).update()) {
270+
const subs = dep.subs!
271+
if (subs.nextSub !== undefined) {
272+
shallowPropagate(subs)
271273
}
272-
while (checkDepth--) {
273-
const computed = current.sub as Computed
274-
const firstSub = computed.subs!
275-
276-
if (computed.update()) {
277-
if (firstSub.nextSub !== undefined) {
278-
shallowPropagate(firstSub)
279-
current = prevLinks!.target
280-
prevLinks = prevLinks!.linked
281-
} else {
282-
current = firstSub
283-
}
284-
continue
285-
}
286-
287-
if (firstSub.nextSub !== undefined) {
288-
if ((current = prevLinks!.target.nextDep!) === undefined) {
289-
return false
290-
}
291-
prevLinks = prevLinks!.linked
292-
continue top
293-
}
294-
295-
return false
296-
}
297-
return true
274+
dirty = true
298275
}
299276
} else if (
300277
(depFlags &
301278
(SubscriberFlags.Computed | SubscriberFlags.PendingComputed)) ===
302279
(SubscriberFlags.Computed | SubscriberFlags.PendingComputed)
303280
) {
304-
dep.flags = depFlags & ~SubscriberFlags.PendingComputed
305-
if (current.nextSub !== undefined || current.prevSub !== undefined) {
306-
prevLinks = { target: current, linked: prevLinks }
281+
const depSubs = dep.subs!
282+
if (depSubs.nextSub !== undefined) {
283+
depSubs.prevSub = link
307284
}
308-
++checkDepth
309-
current = dep.deps!
285+
link = dep.deps!
286+
++stack
310287
continue
311288
}
312289
}
313290

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

0 commit comments

Comments
 (0)