From: Ori Livneh Date: Mon, 5 Oct 2015 18:39:13 +0000 (-0700) Subject: resourceloader: Tiny optimization to ResourceLoader::isValidModuleName() X-Git-Tag: 1.31.0-rc.0~9558 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=e9bafa0ed2a8c064cc43c673dd4f9efdb812045c;p=lhc%2Fweb%2Fwiklou.git resourceloader: Tiny optimization to ResourceLoader::isValidModuleName() This is a micro-optimization, but ResourceLoader is so well-optimized at this point that the call to PCRE accounts for 1.25% of all load.php CPU time. So might as well making it a tiny bit faster. Change-Id: Iefab804a6ca6d54ce230958513a3bea44f4e7c62 --- diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 002b4eac8c..77ceff66df 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -1580,7 +1580,7 @@ MESSAGE; * @return bool Whether $moduleName is a valid module name */ public static function isValidModuleName( $moduleName ) { - return !preg_match( '/[|,!]/', $moduleName ) && strlen( $moduleName ) <= 255; + return strcspn( $moduleName, '!,|', 0, 255 ) === strlen( $moduleName ); } /**