From: Antoine Musso Date: Wed, 29 May 2013 09:16:25 +0000 (+0200) Subject: wfIniGetBool: reduce strtolower() calls X-Git-Tag: 1.31.0-rc.0~19553 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=8bfe2518f78093bc104013a9d8b6d3d8d0d7025f;p=lhc%2Fweb%2Fwiklou.git wfIniGetBool: reduce strtolower() calls We were calling strtolower() up to three times. As a micro optimization, call it once around ini_get() and do the logical checks against the variable containing the lower case output. Change-Id: I16c149fbb9de84d7b6f3e68da06de208c5572b7c --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 78fcb8b941..1c6f642a1e 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2593,11 +2593,11 @@ function in_string( $needle, $str, $insensitive = false ) { * @return Bool */ function wfIniGetBool( $setting ) { - $val = ini_get( $setting ); + $val = strtolower( ini_get( $setting ) ); // 'on' and 'true' can't have whitespace around them, but '1' can. - return strtolower( $val ) == 'on' - || strtolower( $val ) == 'true' - || strtolower( $val ) == 'yes' + return $val == 'on' + || $val == 'true' + || $val == 'yes' || preg_match( "/^\s*[+-]?0*[1-9]/", $val ); // approx C atoi() function }