Skip to content

Commit

Permalink
MDL-27120: Cache dirname transformations in progressive_parser::dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Levi authored and Rajesh Taneja committed May 29, 2012
1 parent 28729e2 commit 066af1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backup/util/xml/parser/progressive_parser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ public function process() {
* 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
Expand Down

0 comments on commit 066af1b

Please sign in to comment.