Skip to content

Commit 9a3eb68

Browse files
acdlitekoto
authored andcommitted
Use bitwise OR to define flag masks (facebook#20044)
Easier to read, harder to mess up. These expressions get simplified by Closure, so there's no runtime impact.
1 parent f3af6e7 commit 9a3eb68

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

packages/react-reconciler/src/ReactFiberFlags.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ export const Hydrating = /* */ 0b0000000010000000000;
3030
export const HydratingAndUpdate = /* */ 0b0000000010000000100;
3131
export const Visibility = /* */ 0b0000000100000000000;
3232

33-
// Passive & Update & Callback & Ref & Snapshot
34-
export const LifecycleEffectMask = /* */ 0b0000000001110100100;
33+
export const LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot;
3534

36-
// Union of all host effects
35+
// Union of all commit flags (flags with the lifetime of a particular commit)
3736
export const HostEffectMask = /* */ 0b0000000111111111111;
3837

3938
// These are not really side effects, but we still reuse this field.
@@ -50,7 +49,14 @@ export const ForceUpdateForLegacySuspense = /* */ 0b0001000000000000000;
5049
// and instead rely on the static flag as a signal that there may be cleanup work.
5150
export const PassiveStatic = /* */ 0b0010000000000000000;
5251

53-
// Union of side effect groupings as pertains to subtreeFlags
52+
// These flags allow us to traverse to fibers that have effects on mount
53+
// without traversing the entire tree after every commit for
54+
// double invoking
55+
export const MountLayoutDev = /* */ 0b0100000000000000000;
56+
export const MountPassiveDev = /* */ 0b1000000000000000000;
57+
58+
// Groups of flags that are used in the commit phase to skip over trees that
59+
// don't contain effects, by checking subtreeFlags.
5460

5561
export const BeforeMutationMask =
5662
Snapshot |
@@ -62,17 +68,12 @@ export const BeforeMutationMask =
6268
Deletion | Visibility
6369
: 0);
6470

65-
export const MutationMask = /* */ 0b0000000110010011110;
66-
export const LayoutMask = /* */ 0b0000000000010100100;
67-
export const PassiveMask = /* */ 0b0000000001000001000;
71+
export const MutationMask =
72+
Placement | Update | Deletion | ContentReset | Ref | Hydrating | Visibility;
73+
export const LayoutMask = Update | Callback | Ref;
74+
export const PassiveMask = Passive | Deletion;
6875

6976
// Union of tags that don't get reset on clones.
7077
// This allows certain concepts to persist without recalculting them,
7178
// e.g. whether a subtree contains passive effects or portals.
72-
export const StaticMask = /* */ 0b0010000000000000000;
73-
74-
// These flags allow us to traverse to fibers that have effects on mount
75-
// without traversing the entire tree after every commit for
76-
// double invoking
77-
export const MountLayoutDev = /* */ 0b0100000000000000000;
78-
export const MountPassiveDev = /* */ 0b1000000000000000000;
79+
export const StaticMask = PassiveStatic;

0 commit comments

Comments
 (0)