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
* @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 );
}
/**