MDL-27120: Cache dirname transformations in progressive_parser::dirname

This commit is contained in:
Tony Levi
2012-05-21 11:02:16 +08:00
committed by Rajesh Taneja
parent 16bf868513
commit 55f6d9d378
@@ -149,7 +149,15 @@ class progressive_parser {
* handling parser paths, see MDL-24381
*/
public static function dirname($path) {
return str_replace('\\', '/', dirname($path));
static $cache = array();
if (!isset($cache[$path])) {
if (count($cache) > 4096)
$cache = array();
$cache[$path] = str_replace('\\', '/', dirname($path));
}
return $cache[$path];
}
// Protected API starts here