WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/26/2015 05:47:53 AM (7 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-base.php

    r31212 r31554  
    372372        $attarray = preg_split('//', $mode);
    373373
    374         for ($i=0; $i < count($attarray); $i++)
    375            if ($key = array_search($attarray[$i], $legal))
     374        for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
     375           if ($key = array_search($attarray[$i], $legal)) {
    376376               $realmode .= $legal[$key];
     377           }
     378        }
    377379
    378380        $mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
Note: See TracChangeset for help on using the changeset viewer.