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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize loop in lint() #245

Merged
merged 3 commits into from
Jul 1, 2019
Merged

Conversation

TrevorBurnham
Copy link
Contributor

Re: #193

@amilajack I took a look at the performance here, and found that a surprising amount of the cost of the lint() function is coming from those polyfills.has() lookups, even when polyfills is a very small set (the project I tested this change against has only 3). So the main optimization here is:

Before

  • filter rules down to those that aren't polyfilled
  • Run remaining rules through rule.isValid()

After

  • Make a single pass through the rules instead of using a separate filter step
  • Check rule.isValid() before checking for polyfills

This simple change cut the time it takes to run compat/compat against my project by more than half, from ~13s to ~5.5s! 馃槷

@amilajack
Copy link
Owner

Thank you so much for this! I'll cut a preminor for this. Also would love if you could update the changelog to describe these changes. Let's add these changes to 3.3.0.

@TrevorBurnham
Copy link
Contributor Author

Also would love if you could update the changelog to describe these changes.

Sure thing! How does this look? f681f68

@amilajack
Copy link
Owner

Awesome! Thanks again Trevor!

@amilajack amilajack merged commit 5e4fc13 into amilajack:master Jul 1, 2019
@amilajack
Copy link
Owner

Published this to eslint-plugin-compat@next 馃帀 馃帀 馃帀

@TrevorBurnham TrevorBurnham deleted the 193-perf branch July 1, 2019 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants