Don't call the size function count() as part of a test condition in loops. Compute the size beforehand, and not on each iteration.

Scrutinizer added a Performance label: these are the only violations.

See #30799.


git-svn-id: https://develop.svn.wordpress.org/trunk@31554 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-02-26 05:47:53 +00:00
parent a524e05572
commit 79706ee8a8
5 changed files with 9 additions and 7 deletions
@@ -371,9 +371,11 @@ class WP_Filesystem_Base {
$legal = array('', 'w', 'r', 'x', '-');
$attarray = preg_split('//', $mode);
for ($i=0; $i < count($attarray); $i++)
if ($key = array_search($attarray[$i], $legal))
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
if ($key = array_search($attarray[$i], $legal)) {
$realmode .= $legal[$key];
}
}
$mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');