Skip to content

Commit ef76b7e

Browse files
authored
Cache subsequent glob calls
1 parent 9b8d557 commit ef76b7e

File tree

1 file changed

+6
-0
lines changed
  • lib/internal/Magento/Framework/Filesystem

1 file changed

+6
-0
lines changed

lib/internal/Magento/Framework/Filesystem/Glob.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
class Glob extends LaminasGlob
1616
{
17+
protected static $cache = [];
1718
/**
1819
* Find pathnames matching a pattern.
1920
*
@@ -24,11 +25,16 @@ class Glob extends LaminasGlob
2425
*/
2526
public static function glob($pattern, $flags = 0, $forceFallback = false)
2627
{
28+
$key = $pattern . '|' . $flags . '|' . ($forceFallback ? 1 : 0);
29+
if (isset(self::$cache[$key])) {
30+
return self::$cache[$key];
31+
}
2732
try {
2833
$result = LaminasGlob::glob($pattern, $flags, $forceFallback);
2934
} catch (LaminasRuntimeException $e) {
3035
$result = [];
3136
}
37+
self::$cache[$key] = $result;
3238
return $result;
3339
}
3440
}

0 commit comments

Comments
 (0)