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

Chore: rewrite parseListConfig for a small perf gain. #9300

Merged
merged 4 commits into from Sep 15, 2017

Conversation

aladdin-add
Copy link
Member

@aladdin-add aladdin-add commented Sep 14, 2017

What is the purpose of this pull request? (put an "X" next to item)

[x] Other, please explain:

What changes did you make? (Give an overview)

Is there anything you'd like reviewers to focus on?

perf tests result (~1.7x):

image

@eslintbot
Copy link

LGTM

1 similar comment
@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I'm skeptical that this actually improves performance by any noticeable amount, because parsing comment configs is a very small portion of an overall linting run. Results from microbenchmarks often don't convert into real end-to-end performance boosts for more complex applications.

That said, I'm fine with this change anyway as a readability improvement over .replace, provided rename one of the variables to be more descriptive.

lib/linter.js Outdated
@@ -145,17 +145,15 @@ function parseJsonConfig(string, location) {
*/
function parseListConfig(string) {
const items = {};
const reg = /[\w-/]+/g;
const rs = string.match(reg);
Copy link
Member

Choose a reason for hiding this comment

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

Can you give this variable a more descriptive name? The name rs doesn't communicate what the variable is doing very well.

Maybe something like elementMatches would be better.

@eslintbot
Copy link

LGTM

@not-an-aardvark not-an-aardvark added the chore This change is not user-facing label Sep 14, 2017
Copy link
Member

@gyandeeps gyandeeps left a comment

Choose a reason for hiding this comment

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

Great. Every drop counts. 💯

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

Just one question from me. Thanks for contributing!

lib/linter.js Outdated
@@ -145,17 +145,15 @@ function parseJsonConfig(string, location) {
*/
function parseListConfig(string) {
const items = {};
const reg = /[\w-/]+/g;
Copy link
Member

Choose a reason for hiding this comment

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

Should this hyphen be escaped?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, before / , it's no need. I was confused.

added a \ in case.

@platinumazure
Copy link
Member

platinumazure commented Sep 14, 2017 via email

@eslintbot
Copy link

LGTM

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@not-an-aardvark not-an-aardvark merged commit 12388d4 into eslint:master Sep 15, 2017
@aladdin-add aladdin-add deleted the perf branch September 15, 2017 02:24
aladdin-add added a commit to aladdin-add/eslint that referenced this pull request Sep 18, 2017
ilyavolodin pushed a commit that referenced this pull request Sep 18, 2017
* Revert "4.7.0"

This reverts commit 439e8e6.

* Revert "Build: changelog update for 4.7.0"

This reverts commit 2ec62f9.

* Revert "Upgrade: Espree v3.5.1 (fixes #9153) (#9314)"

This reverts commit 787b78b.

* Revert "Update: run rules after `node.parent` is already set (fixes #9122) (#9283)"

This reverts commit 1488b51.

* Revert "Docs: fix wrong config in max-len example. (#9309)"

This reverts commit 4431d68.

* Revert "Chore: Revert "avoid handling Rules instances in config-validator" (#9295)"

This reverts commit 9d1df92.

* Revert "Docs: Fix code snippet to refer to the correct option (#9313)"

This reverts commit 7d24dde.

* Revert "�Chore: rewrite parseListConfig for a small perf gain. (#9300)"

This reverts commit 12388d4.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 15, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants