Skip to content

Commit

Permalink
refactor: simplify conditionals in propagate function for better read…
Browse files Browse the repository at this point in the history
…ability
  • Loading branch information
johnsoncodehk committed Dec 25, 2024
1 parent 1fca0d6 commit 198c1b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,8 @@ export function propagate(link: Link, targetFlag: SubscriberFlags = SubscriberFl
const subFlags = sub.flags;

if (!(subFlags & SubscriberFlags.Tracking)) {
if (
(
!(subFlags & (SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty))
&& (sub.flags = subFlags | targetFlag, true)
)
|| (
subFlags & SubscriberFlags.Recursed
&& (sub.flags = (subFlags & ~SubscriberFlags.Recursed) | targetFlag, true)
)
) {
if (!(subFlags & (SubscriberFlags.Recursed | SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty))) {
sub.flags = (subFlags & ~SubscriberFlags.Recursed) | targetFlag;
const subSubs = (sub as Dependency).subs;
if (subSubs !== undefined) {
propagate(
Expand Down
12 changes: 2 additions & 10 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,8 @@ export function propagate(subs: Link): void {
const subFlags = sub.flags;

if (!(subFlags & SubscriberFlags.Tracking)) {
if (
(
!(subFlags & (SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty))
&& (sub.flags = subFlags | targetFlag, true)
)
|| (
subFlags & SubscriberFlags.Recursed
&& (sub.flags = (subFlags & ~SubscriberFlags.Recursed) | targetFlag, true)
)
) {
if (!(subFlags & (SubscriberFlags.Recursed | SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty))) {
sub.flags = (subFlags & ~SubscriberFlags.Recursed) | targetFlag;
const subSubs = (sub as Dependency).subs;
if (subSubs !== undefined) {
if (subSubs.nextSub !== undefined) {
Expand Down

0 comments on commit 198c1b6

Please sign in to comment.