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

Components: Optimize SlotFill rendering to avoid props destructuring #10921

Merged
merged 1 commit into from
Oct 23, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Oct 22, 2018

Related: #5952

This pull request seeks to optimize the rendering of components created through createSlotFill to avoid an unnecessary props destructuring. These components are considered to be hot code paths, being called upwards of thousands of times in the authoring of one or few paragraphs of text (itself an issue worth exploring).

The change is simple; since React considers children as a prop (and, in fact, always normalizes back to a prop anyways), there's no need to extract it separately, and it can be included in the default spread of props.

The issue boils down to the effective transpiled output of a destructuring:

Note in above the iteration which would occur through _objectWithoutProperties in the separate treatment, which is avoided altogether in the implementation proposed here.

Testing instructions:

There should be no effective difference in behavior.

Ensure Slot/Fill works as expected (sidebar, toolbars, plugins).

@aduth aduth added [Type] Performance Related to performance efforts [Type] Code Quality Issues or PRs that relate to code quality labels Oct 22, 2018
@aduth aduth requested a review from gziolo October 22, 2018 20:11
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

LGTM 😅

@gziolo gziolo merged commit 80e782c into master Oct 23, 2018
@gziolo gziolo added this to the 4.2 milestone Oct 23, 2018
@gziolo gziolo deleted the remove/create-slot-fill-destructure branch October 23, 2018 06:07
daniloercoli added a commit that referenced this pull request Oct 23, 2018
…rnmobile/fix-validation-errorrs-after-block-splitting

* 'master' of https://github.com/WordPress/gutenberg:
  Add some new url helper functions (#10885)
  Components: Avoid SlotFill props destructuring (#10921)
  Update Package Changelogs (#10887)
  chore(release): publish
  Update plugin version to 4.1 RC2. (#10893)
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants