-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Forwardport] Performance: remove count() form the condition section of a loop #14195
[Forwardport] Performance: remove count() form the condition section of a loop #14195
Conversation
@coderimus @ihor-sviziev @ishakhsuvarov @miguelbalparda hi guys, unfortunately Can we revert original PR or mark it as not needed for forwardporting maybe instead of porting it to |
@orlangur thank you for your reply! I have just one question: All of the above changes are working with Also I think if we will ommit creating |
Hi @coderimus, all of them. Just that there is no need to "not call method twice" from performance perspective. The only overhead is one function call and it is negligible compared to a loop body. It would make some difference only if we did like 100k-1M iterations with a tiny loop body. |
Hi @orlangur @miguelbalparda , actually we will not have there big changes in performance, because there will not be thousands of iterations, but keeping it different in |
Hi @miguelbalparda, thank you for the review. |
@ihor-sviziev, thanks for the input
That's another option which I raised initially. Personally I'm not a big fan of having two lines of code where we had only one before with the same result. @coderimus assuming both versions of code perform equally fast, which one would you prefer from readability perspective? |
…tion section of a loop #14195
Original Pull Request
#13173
Description
In this PR I removed the
count()
method from condition section for some loops. When this method is used in the loop condition it will be executed every iteration which is not so good for process time (performance).Fixed Issues (if relevant)
N/A
Manual testing scenarios
N/A
Contribution checklist