From e9bafa0ed2a8c064cc43c673dd4f9efdb812045c Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 5 Oct 2015 11:39:13 -0700 Subject: [PATCH] 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 --- includes/resourceloader/ResourceLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ); } /** -- 2.20.1