-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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] improve performance for detecting class components #3267
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3267 +/- ##
==========================================
- Coverage 97.69% 97.68% -0.01%
==========================================
Files 121 121
Lines 8583 8593 +10
Branches 3120 3127 +7
==========================================
+ Hits 8385 8394 +9
- Misses 198 199 +1
Continue to review full report at Codecov.
|
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.
Changes in general look good!
&& /^(Pure)?Component$/.test(node.superClass.property.name); | ||
} | ||
if (node.superClass.type === 'Identifier') { | ||
return /^(Pure)?Component$/.test(node.superClass.name); |
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.
is there a speed improvement from caching this non-global regex at module level?
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.
I tried and didn't see a speed improvement. I suppose the compiler can compile the regexp once and reuse it afterwards.
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.
This contrasts with the previous line RegExp(
^()
where v8 have to compile the regexp at runtime at every function call.
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.
we'll land it as-is then for now
4836b29
to
161317e
Compare
Benchmark on the eslint repo with
extends: plugin:react/recommended
andtime npx eslint .
(real time):Benchmark with
TIMING=10 npx eslint .
: