-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Performance: remove count() form the condition section of a loop #13173
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
Performance: remove count() form the condition section of a loop #13173
Conversation
|
Hi @coderimus |
| $expression = trim($expression); | ||
| foreach ($this->_operations as $operation) { | ||
| $splittedExpr = preg_split('/\\' . $operation . '/', $expression, -1, PREG_SPLIT_DELIM_CAPTURE); | ||
| if (count($splittedExpr) > 1) { |
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 assume that old check would not pass if $splittedExpr is and array with 1 element, while new one would pass.
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.
@ishakhsuvarov thank you for your review! You are totally right. Fix uploaded.
|
@ishakhsuvarov requested changes added. Please, review them when this will be suitable for you :) |
|
Thanks @coderimus |
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