Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _ctor field from Lazy components #18217

Merged
merged 6 commits into from
Mar 5, 2020

Conversation

sebmarkbage
Copy link
Collaborator

This field is not needed because it's only used before we've initialized, and we don't have anything else to store before we've initialized.

This isn't an important perf optimization by itself but this refactor is motivated by lining it up with the same work on Blocks.

We can type each condition.
This field is not needed because it's only used before we've initialized,
and we don't have anything else to store before we've initialized.
We try not to break across minors but it's no guarantee.
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 5, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 5, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 01bf197:

Sandbox Source
exciting-maxwell-4i44f Configuration

@sizebot
Copy link

sizebot commented Mar 5, 2020

Details of bundled changes.

Comparing: 2fe0fbb...01bf197

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js 0.0% 0.0% 406.33 KB 406.37 KB 74.07 KB 74.08 KB FB_WWW_PROFILING
react-dom-server.browser.development.js +0.3% +0.3% 134.78 KB 135.19 KB 34.64 KB 34.75 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.15 KB 1.15 KB 653 B 654 B NODE_PROD
react-dom-server.browser.production.min.js 🔺+0.1% 🔺+0.1% 20.03 KB 20.05 KB 7.41 KB 7.42 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 55.86 KB 55.86 KB 14.46 KB 14.46 KB NODE_DEV
react-dom.development.js 0.0% +0.1% 883.74 KB 884.16 KB 194.69 KB 194.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.99 KB 9.99 KB 3.36 KB 3.37 KB NODE_PROD
react-dom.production.min.js 0.0% 🔺+0.1% 116 KB 116.01 KB 37.14 KB 37.17 KB UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 119.53 KB 119.54 KB 38.34 KB 38.33 KB UMD_PROFILING
react-dom.development.js 0.0% +0.1% 841.01 KB 841.41 KB 192.31 KB 192.42 KB NODE_DEV
react-dom-server.node.development.js +0.3% +0.3% 129.09 KB 129.48 KB 34.47 KB 34.58 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 116.08 KB 116.09 KB 36.5 KB 36.5 KB NODE_PROD
react-dom-server.node.production.min.js 🔺+0.1% 🔺+0.1% 20.36 KB 20.38 KB 7.52 KB 7.53 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 119.76 KB 119.77 KB 37.58 KB 37.58 KB NODE_PROFILING
ReactDOM-dev.js 0.0% +0.1% 939.37 KB 939.77 KB 209.37 KB 209.49 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 395 KB 395.04 KB 71.89 KB 71.91 KB FB_WWW_PROD
ReactDOMTesting-dev.js 0.0% +0.1% 899 KB 899.4 KB 200.88 KB 201.01 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 382.25 KB 382.29 KB 69.63 KB 69.64 KB FB_WWW_PROD
react-dom-server.browser.development.js +0.3% +0.3% 127.87 KB 128.27 KB 34.21 KB 34.33 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 53.77 KB 53.77 KB 14 KB 14 KB UMD_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 382.25 KB 382.29 KB 69.63 KB 69.64 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 🔺+0.1% 🔺+0.1% 19.95 KB 19.97 KB 7.37 KB 7.38 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.34 KB 3.34 KB 1.26 KB 1.26 KB UMD_DEV
ReactDOMServer-dev.js +0.3% +0.3% 137.7 KB 138.1 KB 35.08 KB 35.2 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+0.1% 🔺+0.1% 47.45 KB 47.49 KB 11.04 KB 11.05 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 10.79 KB 10.79 KB 4.09 KB 4.09 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 58.9 KB 58.9 KB 14.7 KB 14.7 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1013 B 1013 B 601 B 602 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.26 KB 10.26 KB 3.49 KB 3.49 KB UMD_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js +0.1% +0.1% 614.29 KB 614.69 KB 132.75 KB 132.86 KB RN_OSS_DEV
ReactNativeRenderer-dev.js +0.1% +0.1% 632.19 KB 632.59 KB 137.02 KB 137.13 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 0.0% 0.0% 259.75 KB 259.8 KB 45.19 KB 45.2 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% 0.0% 271.09 KB 271.13 KB 47.33 KB 47.34 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% 0.0% 251.72 KB 251.76 KB 43.7 KB 43.71 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% 0.0% 263.05 KB 263.1 KB 45.87 KB 45.88 KB RN_OSS_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +0.1% +0.1% 567.29 KB 567.69 KB 118.85 KB 118.97 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 233.79 KB 233.84 KB 39.73 KB 39.74 KB FB_WWW_PROD
react-art.development.js +0.1% +0.1% 614.59 KB 615.01 KB 129.66 KB 129.78 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 104.2 KB 104.21 KB 31.6 KB 31.61 KB UMD_PROD
react-art.development.js +0.1% +0.1% 519.57 KB 519.97 KB 112.04 KB 112.16 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 69.23 KB 69.25 KB 20.78 KB 20.79 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 553.06 KB 553.46 KB 116.7 KB 116.82 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 38.39 KB 38.39 KB 9.29 KB 9.29 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.91 KB 12.91 KB 3.93 KB 3.93 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 551.91 KB 552.33 KB 114.86 KB 114.97 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 71.2 KB 71.22 KB 21.65 KB 21.66 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 525.99 KB 526.38 KB 113.55 KB 113.67 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 71.02 KB 71.04 KB 21.34 KB 21.34 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.1% 555.54 KB 555.93 KB 117.48 KB 117.59 KB NODE_DEV
react-reconciler-reflection.development.js +0.4% +0.7% 16.17 KB 16.24 KB 4.93 KB 4.96 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 73.69 KB 73.71 KB 21.76 KB 21.77 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.8 KB 2.8 KB 1.2 KB 1.2 KB NODE_PROD
react-reconciler-persistent.development.js +0.1% +0.1% 554.18 KB 554.58 KB 117.33 KB 117.45 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% 0.0% 73.7 KB 73.72 KB 21.77 KB 21.78 KB NODE_PROD

ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1%

Size changes (stable)

Generated by 🚫 dangerJS against 01bf197

@sizebot
Copy link

sizebot commented Mar 5, 2020

Details of bundled changes.

Comparing: 2fe0fbb...01bf197

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 633.76 KB 634.18 KB 133.08 KB 133.2 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 106.63 KB 106.64 KB 32.24 KB 32.25 KB UMD_PROD
react-art.development.js +0.1% +0.1% 538 KB 538.39 KB 115.48 KB 115.6 KB NODE_DEV
react-art.production.min.js 0.0% 🔺+0.1% 71.6 KB 71.62 KB 21.43 KB 21.44 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 541.58 KB 541.98 KB 113.58 KB 113.71 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 226.62 KB 226.66 KB 38.51 KB 38.52 KB FB_WWW_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 123.82 KB 123.84 KB 38.64 KB 38.64 KB NODE_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 58.91 KB 58.91 KB 14.71 KB 14.71 KB UMD_DEV
ReactDOM-dev.js 0.0% +0.1% 897.13 KB 897.53 KB 200.49 KB 200.61 KB FB_WWW_DEV
ReactDOMServer-dev.js +0.3% +0.3% 136.85 KB 137.25 KB 34.94 KB 35.06 KB FB_WWW_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.96 KB 10.96 KB 4.17 KB 4.17 KB UMD_PROD
ReactDOMTesting-dev.js 0.0% +0.1% 872.36 KB 872.76 KB 195.35 KB 195.47 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 368.7 KB 368.74 KB 67.45 KB 67.46 KB FB_WWW_PROD
ReactDOMTesting-profiling.js 0.0% 0.0% 368.7 KB 368.74 KB 67.45 KB 67.46 KB FB_WWW_PROFILING
react-dom-server.node.development.js +0.3% +0.3% 130.6 KB 131 KB 34.69 KB 34.81 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.81 KB 10.81 KB 4.1 KB 4.1 KB NODE_PROD
react-dom-server.node.production.min.js 🔺+0.1% 🔺+0.1% 20.82 KB 20.83 KB 7.6 KB 7.61 KB NODE_PROD
react-dom.development.js 0.0% +0.1% 912.43 KB 912.84 KB 199.6 KB 199.77 KB UMD_DEV
react-dom-server.browser.development.js +0.3% +0.3% 136.37 KB 136.78 KB 34.84 KB 34.96 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 119.87 KB 119.89 KB 38.29 KB 38.28 KB UMD_PROD
react-dom-server.browser.production.min.js 🔺+0.1% 🔺+0.1% 20.49 KB 20.51 KB 7.5 KB 7.51 KB UMD_PROD
react-dom.profiling.min.js 0.0% +0.1% 123.52 KB 123.54 KB 39.44 KB 39.47 KB UMD_PROFILING
react-dom.development.js 0.0% +0.1% 868.51 KB 868.91 KB 197.21 KB 197.31 KB NODE_DEV
react-dom-server.browser.development.js +0.3% +0.3% 129.38 KB 129.78 KB 34.43 KB 34.55 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 120.02 KB 120.04 KB 37.52 KB 37.52 KB NODE_PROD
react-dom-server.browser.production.min.js 🔺+0.1% 🔺+0.1% 20.41 KB 20.43 KB 7.45 KB 7.46 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 370.67 KB 370.72 KB 67.55 KB 67.55 KB FB_WWW_PROD
ReactDOMServer-prod.js 🔺+0.1% 🔺+0.1% 46.74 KB 46.78 KB 10.86 KB 10.87 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 381.94 KB 381.98 KB 69.66 KB 69.67 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 55.87 KB 55.87 KB 14.47 KB 14.47 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10 KB 10 KB 3.37 KB 3.37 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.16 KB 1.16 KB 661 B 662 B NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 698 B 699 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 2.95 KB 2.95 KB 1.18 KB 1.18 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1 KB 1 KB 609 B 610 B NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 553.07 KB 553.47 KB 116.7 KB 116.83 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 38.4 KB 38.4 KB 9.3 KB 9.3 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.92 KB 12.92 KB 3.94 KB 3.94 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 551.94 KB 552.35 KB 114.87 KB 114.98 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 71.23 KB 71.25 KB 21.66 KB 21.67 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 526.01 KB 526.41 KB 113.56 KB 113.68 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 71.04 KB 71.06 KB 21.35 KB 21.36 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 0.0% 0.0% 259.77 KB 259.81 KB 45.2 KB 45.21 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% 0.0% 271.1 KB 271.15 KB 47.34 KB 47.35 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% 0.0% 251.73 KB 251.77 KB 43.71 KB 43.72 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% 0.0% 263.07 KB 263.11 KB 45.88 KB 45.89 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 616.94 KB 617.34 KB 133.08 KB 133.2 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 0.0% 251.88 KB 251.93 KB 43.74 KB 43.75 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% +0.1% 632.2 KB 632.6 KB 137.03 KB 137.13 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% 0.0% 263.21 KB 263.26 KB 45.93 KB 45.93 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 634.83 KB 635.23 KB 137.37 KB 137.47 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% 0.0% 259.91 KB 259.96 KB 45.22 KB 45.23 KB RN_FB_PROD
ReactNativeRenderer-profiling.js 0.0% 0.0% 271.24 KB 271.29 KB 47.39 KB 47.4 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 614.3 KB 614.7 KB 132.75 KB 132.87 KB RN_OSS_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js +0.1% +0.1% 554.19 KB 554.59 KB 117.33 KB 117.46 KB NODE_DEV
react-reconciler-reflection.development.js +0.4% +0.6% 16.18 KB 16.25 KB 4.93 KB 4.97 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% 0.0% 73.71 KB 73.73 KB 21.78 KB 21.78 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.81 KB 2.81 KB 1.21 KB 1.21 KB NODE_PROD
react-reconciler.development.js +0.1% +0.1% 576.29 KB 576.69 KB 121.36 KB 121.48 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 76.46 KB 76.48 KB 22.44 KB 22.44 KB NODE_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against 01bf197

lazyComponent._status = Pending;
const ctor = lazyComponent._ctor;
let ctor = lazyComponent._result;
if (!ctor) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coercion is OK here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we detect existence of something unknown things we tend to do this type of check.

The "react" package owns the data structure of the Lazy component. It
creates it and decides how any downstream renderer may use it.
export const Uninitialized = -1;
export const Pending = 0;
export const Resolved = 1;
export const Rejected = 2;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also upstreamed all of this to the isomorphic package since it owns this data structure. I'll think a bit how we can move the other two helpers out of /shared.

Apparently we can't depend on react/src/ because the whole package is
considered "external" as far as rollup is concerned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants