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 a475c94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 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;
16 changes: 1 addition & 15 deletions packages/shared/ReactVersion.js
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// TODO: this is special because it gets imported during build.
//
// It exists as a placeholder so that DevTools can support work tag changes between releases.
// When we next publish a release, update the matching TODO in backend/renderer.js
// TODO: This module is used both by the release scripts and to expose a version
// at runtime. We should instead inject the version number as part of the build
// process, and use the ReactVersions.js module as the single source of truth.
export default '19.0.0';
export default '19.0.0-PLACEHOLDER';

0 comments on commit a475c94

Please sign in to comment.