From b42b638aebd8e9aba06905a1179044e4dc3d81dd Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Wed, 8 Jan 2025 15:19:22 +0800 Subject: [PATCH] refactor: streamline rollback logic in propagate function --- src/system.ts | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/system.ts b/src/system.ts index 3f07e72..b56763c 100644 --- a/src/system.ts +++ b/src/system.ts @@ -181,23 +181,20 @@ export function propagate(subs: Link): void { } if ((link = subs.nextSub!) === undefined) { - if (stack) { - let dep = subs.dep; - do { - --stack; - const depSubs = dep.subs!; - const prevLink = depSubs.prevSub!; - depSubs.prevSub = undefined; - link = prevLink.nextSub!; - if (link !== undefined) { - subs = link; - targetFlag = stack - ? SubscriberFlags.ToCheckDirty - : SubscriberFlags.Dirty; - continue top; - } - dep = prevLink.dep; - } while (stack); + while (stack) { + --stack; + const dep = subs.dep; + const depSubs = dep.subs!; + subs = depSubs.prevSub!; + depSubs.prevSub = undefined; + link = subs.nextSub!; + if (link !== undefined) { + subs = link; + targetFlag = stack + ? SubscriberFlags.ToCheckDirty + : SubscriberFlags.Dirty; + continue top; + } } break; }