From 8bfe2518f78093bc104013a9d8b6d3d8d0d7025f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Wed, 29 May 2013 11:16:25 +0200 Subject: [PATCH] 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 --- includes/GlobalFunctions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 } -- 2.20.1