-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
perf: preinitialize typeCheck RegExp #10990
Conversation
Maybe further improvements could be made by removing the regular expression completely and using standard string manipulation methods. |
Is there anything else, that needs to be done before merging? @posva |
@SebastianSpeitel You don't need to do anything else, thank you :) |
I made this PR 2 months ago. Is there a reasons for this taking so long? |
@SebastianSpeitel cached it may be better ? const getType = cached(function getType (fn) {
var match = fn && fn.toString().match(/^\s*function (\w+)/);
return match ? match[1] : ''
}) |
Both could be optimal. |
but the |
Why not just |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
After looking at the performance of one of my apps, I noticed, the function, that took the most time summed up was
getType()
, defined in [1] taking 200ms. I noticed the regular expression getting created for each call and measured again including the proposed improvement, which took the time down to 150ms. To make sure I changed it back to confirm and it again timed at 200ms.[1]
vue/src/core/util/props.js
Lines 182 to 185 in b07087d