-
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
Avoid calling function repetitively in loop conditionals #16027
Avoid calling function repetitively in loop conditionals #16027
Conversation
@@ -200,7 +200,7 @@ public function testTierPrices($priceScope, $expectedWebsiteId) | |||
$this->assertTrue(is_array($tpArray)); | |||
$this->assertEquals(sizeof($tps), sizeof($tpArray)); | |||
|
|||
for ($i = 0; $i < sizeof($tps); $i++) { | |||
for ($i = 0, $iMax = sizeof($tps); $i < $iMax; $i++) { |
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 also replace sizeof with count?
It's alias http://php.net/manual/en/function.sizeof.php
@@ -231,7 +231,7 @@ public function testTierPrices($priceScope, $expectedWebsiteId) | |||
$this->assertEquals(50, $tpRest->getExtensionAttributes()->getPercentageValue()); | |||
} | |||
|
|||
for ($i = 0; $i < sizeof($tps); $i++) { | |||
for ($i = 0, $iMax = sizeof($tps); $i < $iMax; $i++) { |
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 also replace sizeof with count?
It's alias http://php.net/manual/en/function.sizeof.php
@@ -344,7 +344,7 @@ public function getChartUrl($directUrl = true) | |||
} | |||
} else { | |||
// EXTENDED ENCODING | |||
for ($j = 0; $j < sizeof($thisdataarray); $j++) { | |||
for ($j = 0, $jMax = sizeof($thisdataarray); $j < $jMax; $j++) { |
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 also replace sizeof with count?
It's alias http://php.net/manual/en/function.sizeof.php
@@ -331,7 +331,7 @@ public function getChartUrl($directUrl = true) | |||
$thisdataarray = $serie; | |||
if ($this->_encoding == "s") { | |||
// SIMPLE ENCODING | |||
for ($j = 0; $j < sizeof($thisdataarray); $j++) { | |||
for ($j = 0, $jMax = sizeof($thisdataarray); $j < $jMax; $j++) { |
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 also replace sizeof with count?
It's alias http://php.net/manual/en/function.sizeof.php
@lfluvisotto |
Avoid calling function repetitively in loop conditionals.
Description
Avoid calling function repetitively in loop conditionals for better performance.
Fixed Issues
N/A