From: Tim Starling Date: Fri, 19 Nov 2010 06:49:15 +0000 (+0000) Subject: * Some tweaks to wfMemoryLimit() to make it a bit faster. X-Git-Tag: 1.31.0-rc.0~33815 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=6dcca60f655ab660fd370d85f237dfbe2f94cb87;p=lhc%2Fweb%2Fwiklou.git * Some tweaks to wfMemoryLimit() to make it a bit faster. * Fixed inappropriate use of empty(), added "break missing" comments as in zend_atol() --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a7d91a25c1..7e3f53dec2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3451,8 +3451,8 @@ function wfObjectToArray( $object, $recursive = true ) { function wfMemoryLimit() { global $wgMemoryLimit; $memlimit = wfShorthandToInteger( ini_get( 'memory_limit' ) ); - $conflimit = wfShorthandToInteger( $wgMemoryLimit ); if( $memlimit != -1 ) { + $conflimit = wfShorthandToInteger( $wgMemoryLimit ); if( $conflimit == -1 ) { wfDebug( "Removing PHP's memory limit\n" ); wfSuppressWarnings(); @@ -3477,17 +3477,22 @@ function wfMemoryLimit() { */ function wfShorthandToInteger( $string = '' ) { $string = trim( $string ); - if( empty( $string ) ) { + if( $string === '' ) { return -1; } - $last = strtolower( $string[strlen( $string ) - 1] ); + $last = $string[strlen( $string ) - 1]; $val = intval( $string ); switch( $last ) { case 'g': + case 'G': $val *= 1024; + // break intentionally missing case 'm': + case 'M': $val *= 1024; + // break intentionally missing case 'k': + case 'K': $val *= 1024; }