-
Notifications
You must be signed in to change notification settings - Fork 7k
[misc] optimize for loops #5744
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
Conversation
|
Thanks for this. How did you find these cases? Did you look manually? Is there a lint rule we can set up to avoid this in the future? |
|
@marwahaha I look manually for these cases. I don't have any idea about such rule but we can look for this rule. |
src/lib/create/from-string.js
Outdated
| tzFormat; | ||
| tzFormat, | ||
| isoDateLen = isoDates.length, | ||
| isoTimeLen = isoTimes.length; |
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.
Could you change these to isoDatesLen and isoTimesLen?
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.
@marwahaha I have updated these variables
This pull request will improve the performance as I am pre calculating the array length before the for loop execution
For example
arr.length will execute in each iteration which slows our execution. For this I just pre calculate the length and use that variable in each iteration like
I am also attachig the test suite case run time which is decrease by 610ms after changes
Before

After
