Navigation Menu

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

[Refactor] void-dom-elements-no-children: improve performance #2977

Conversation

golopot
Copy link
Contributor

@golopot golopot commented Apr 28, 2021

closes #1126.

The rule spends lots of time inutils.isCreateElement -> isDestructuredFromPragmaImport. This pr reduces that expensive function call by short-circuiting it when possible.

Benchmarks:

Before this pr:
$ TIMING=50 npx eslint . | grep react/void-dom
react/void-dom-elements-no-children             |   263.673 |     3.6%
react/void-dom-elements-no-children             |   256.981 |     3.4%
react/void-dom-elements-no-children             |   230.990 |     3.3%
react/void-dom-elements-no-children             |   235.888 |     3.2%
react/void-dom-elements-no-children             |   251.152 |     3.5%

After this pr:
react/void-dom-elements-no-children             |   106.662 |     1.6%
react/void-dom-elements-no-children             |   106.205 |     1.6%
react/void-dom-elements-no-children             |   106.061 |     1.6%
react/void-dom-elements-no-children             |   103.666 |     1.6%
react/void-dom-elements-no-children             |   103.363 |     1.6%

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks, looks great

@ljharb ljharb force-pushed the issue-1126-void-dom-elements-no-children-perf branch from 6437617 to 1185b37 Compare April 28, 2021 17:49
@ljharb ljharb merged commit 1185b37 into jsx-eslint:master Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

void-dom-elements-no-children performance issue?
2 participants