Make WordPress Core


Ignore:
Timestamp:
02/26/2015 05:47:53 AM (11 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-includes/formatting.php

    r31249 r31554  
    634634        $string = preg_split( '/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
    635635
    636         for ( $i = 0; $i < count( $string ); $i += 2 )
     636        for ( $i = 0, $c = count( $string ); $i < $c; $i += 2 ) {
    637637            $string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset );
    638 
     638        }
    639639        $string = implode( '', $string );
    640640    }
Note: See TracChangeset for help on using the changeset viewer.