-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: Replace some function application with spread operators #10645
Conversation
I ran some performance tests just to see if anything showed up. Seems negligible. Before:
After:
|
@@ -83,7 +83,7 @@ function extractPatterns(patterns, type) { | |||
})); | |||
|
|||
// Flatten. | |||
return Array.prototype.concat.apply([], patternsList); | |||
return [].concat(...patternsList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly be return [...patternsList)]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I tried this and it doesn't work. patternList
is an array of arrays that needs to be flattened. [...patternList]
just shallow-copies the array of arrays. [].concat(...patternsList)
flattens the array. Thanks for the suggestion though, it was worth a try!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain: Just replacing some calls to
Function.prototype.apply
by using spread operators (or, in a few cases,Function.prototype.call
.What changes did you make? (Give an overview)
Replaced some function application with spread operators.
Is there anything you'd like reviewers to focus on?
Not really.