Skip to content

Commit

Permalink
Try shorter property name to get inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Apr 5, 2024
1 parent fcbb369 commit 31552fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions packages/react-dom-bindings/src/client/ReactDOMUpdatePriority.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
const ReactDOMCurrentUpdatePriority =
ReactDOMSharedInternals.ReactDOMCurrentUpdatePriority;

export function setCurrentUpdatePriority(newPriority: EventPriority): void {
ReactDOMCurrentUpdatePriority.current = newPriority;
export function setCurrentUpdatePriority(
newPriority: EventPriority,
// Closure will repeatedly not inline this function when it has arity 1 because
// the function form is shorter than the inlined implementation. We use this second
// argument which is unused to trick closure into inlining because it makes the
// inlined function shorter.
IntentionallyUnusedArgument: mixed,
): void {
ReactDOMCurrentUpdatePriority.cup = newPriority;
}

export function getCurrentUpdatePriority(): EventPriority {
return ReactDOMCurrentUpdatePriority.current;
return ReactDOMCurrentUpdatePriority.cup;
}

export function resolveUpdatePriority(): EventPriority {
const updatePriority = ReactDOMCurrentUpdatePriority.current;
const updatePriority = ReactDOMCurrentUpdatePriority.cup;
if (updatePriority !== NoEventPriority) {
return updatePriority;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/ReactDOMSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type InternalsType = {
componentOrElement: React$Component<any, any>,
) => null | Element | Text),
ReactDOMCurrentUpdatePriority: {
current: EventPriority,
cup: EventPriority,
},
};

Expand All @@ -48,7 +48,7 @@ const Internals: InternalsType = {
},
findDOMNode: null,
ReactDOMCurrentUpdatePriority: {
current: NoEventPriority,
cup: NoEventPriority,
},
};

Expand Down

0 comments on commit 31552fb

Please sign in to comment.