From 78aa79f5ea8926f5b8ca0daaffb3d0b9387f9140 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Mon, 23 Dec 2024 02:48:59 +0800 Subject: [PATCH] perf: remove canPropagate intermediate variable --- src/system.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/system.ts b/src/system.ts index 0a3430c..e91df43 100644 --- a/src/system.ts +++ b/src/system.ts @@ -135,18 +135,16 @@ export function propagate(subs: Link): void { const subFlags = sub.flags; if (!(subFlags & SubscriberFlags.Tracking)) { - let canPropagate = !(subFlags >> 2); - if (!canPropagate) { - if (subFlags & SubscriberFlags.CanPropagate) { - sub.flags = (subFlags & ~SubscriberFlags.CanPropagate) | targetFlag; - canPropagate = true; - } else if (!(subFlags & targetFlag)) { - sub.flags = subFlags | targetFlag; - } - } else { - sub.flags = subFlags | targetFlag; - } - if (canPropagate) { + if ( + ( + !(subFlags >> 2) + && (sub.flags = subFlags | targetFlag, true) + ) + || ( + subFlags & SubscriberFlags.CanPropagate + && (sub.flags = (subFlags & ~SubscriberFlags.CanPropagate) | targetFlag, true) + ) + ) { const subSubs = (sub as Dependency).subs; if (subSubs !== undefined) { if (subSubs.nextSub !== undefined) { @@ -170,6 +168,8 @@ export function propagate(subs: Link): void { } queuedEffectsTail = sub; } + } else { + sub.flags = subFlags | targetFlag; } } else if (isValidLink(link, sub)) { if (!(subFlags >> 2)) {