Skip to content

Commit

Permalink
refactor: streamline propagate function and remove nextSub intermedia…
Browse files Browse the repository at this point in the history
…te variable
  • Loading branch information
johnsoncodehk committed Jan 7, 2025
1 parent d605271 commit e4a4ece
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export function propagate(subs: Link): void {
let targetFlag = SubscriberFlags.Dirty;
let link = subs;
let stack = 0;
let nextSub: Link | undefined;

top: do {
const sub = link.sub;
Expand Down Expand Up @@ -181,16 +180,17 @@ export function propagate(subs: Link): void {
sub.flags = subFlags | targetFlag;
}

if ((nextSub = subs.nextSub) === undefined) {
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 = subs = prevLink.nextSub!;
if (subs !== undefined) {
link = prevLink.nextSub!;
if (link !== undefined) {
subs = link;
targetFlag = stack
? SubscriberFlags.ToCheckDirty
: SubscriberFlags.Dirty;
Expand All @@ -201,12 +201,10 @@ export function propagate(subs: Link): void {
}
break;
}
if (link !== subs) {
targetFlag = stack
? SubscriberFlags.ToCheckDirty
: SubscriberFlags.Dirty;
}
link = subs = nextSub;
subs = link;
targetFlag = stack
? SubscriberFlags.ToCheckDirty
: SubscriberFlags.Dirty;
} while (true);

if (!batchDepth) {
Expand Down

0 comments on commit e4a4ece

Please sign in to comment.