Permalink
Browse files

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

  • Loading branch information...
1 parent 16bf868 commit 55f6d9d3788b68ffedb082edc7ac4aed10a0491e @tlevi tlevi committed with Rajesh Taneja Apr 11, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 backup/util/xml/parser/progressive_parser.class.php
@@ -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

0 comments on commit 55f6d9d

Please sign in to comment.