Skip to content

Commit 716ae0b

Browse files
committed
refactor: streamline propagate function by consolidating conditional checks
1 parent fc5d4ce commit 716ae0b

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/system.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -185,39 +185,38 @@ export function propagate(subs: Link): void {
185185
}
186186
}
187187
} else if (subTrackId === -link.trackId) {
188-
189188
const subDirtyLevel = sub.dirtyLevel;
190-
const notDirty = subDirtyLevel === DirtyLevels.None;
191189

192190
if (subDirtyLevel < dirtyLevel) {
193191
sub.dirtyLevel = dirtyLevel;
194-
}
195-
196-
if (notDirty || sub.canPropagate) {
197-
if (!notDirty) {
198-
sub.canPropagate = false;
199-
}
200192

201-
if ('subs' in sub && sub.subs !== undefined) {
202-
sub.depsTail!.nextDep = link;
203-
dep = sub;
204-
link = sub.subs;
205-
if ('notify' in sub) {
206-
dirtyLevel = DirtyLevels.SideEffectsOnly;
207-
} else {
208-
dirtyLevel = DirtyLevels.MaybeDirty;
193+
const notDirty = subDirtyLevel === DirtyLevels.None;
194+
if (notDirty || sub.canPropagate) {
195+
if (!notDirty) {
196+
sub.canPropagate = false;
209197
}
210-
stack++;
211198

212-
continue;
213-
} else if ('notify' in sub) {
214-
const queuedEffectsTail = System.queuedEffectsTail;
215-
if (queuedEffectsTail !== undefined) {
216-
queuedEffectsTail.nextNotify = sub;
217-
} else {
218-
System.queuedEffects = sub;
199+
if ('subs' in sub && sub.subs !== undefined) {
200+
sub.depsTail!.nextDep = link;
201+
dep = sub;
202+
link = sub.subs;
203+
if ('notify' in sub) {
204+
dirtyLevel = DirtyLevels.SideEffectsOnly;
205+
} else {
206+
dirtyLevel = DirtyLevels.MaybeDirty;
207+
}
208+
stack++;
209+
210+
continue;
211+
} else if ('notify' in sub) {
212+
const queuedEffectsTail = System.queuedEffectsTail;
213+
if (queuedEffectsTail !== undefined) {
214+
queuedEffectsTail.nextNotify = sub;
215+
} else {
216+
System.queuedEffects = sub;
217+
}
218+
System.queuedEffectsTail = sub;
219219
}
220-
System.queuedEffectsTail = sub;
221220
}
222221
}
223222
}

0 commit comments

Comments
 (0)