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 5d28591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 11 additions & 6 deletions packages/react-dom-bindings/src/client/ReactDOMUpdatePriority.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ import {
} from 'react-reconciler/src/ReactEventPriorities';

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 consistently not inline this function when it has arity 1
// however when it has arity 2 even if the second arg is omitted at every
// callsite it seems to inline it even when the internal length of the function
// is much longer. I hope this is consistent enough to rely on across builds
IntentionallyUnusedArgument?: empty,
): void {
ReactDOMSharedInternals.up = newPriority;
}

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

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

function noop() {}
Expand All @@ -47,9 +45,7 @@ const Internals: InternalsType = {
current: DefaultDispatcher,
},
findDOMNode: null,
ReactDOMCurrentUpdatePriority: {
current: NoEventPriority,
},
up /* currentUpdatePriority */: NoEventPriority,
};

export default Internals;

0 comments on commit 5d28591

Please sign in to comment.