From 6d0c8f98c7e0926407e8bac57a8f16138741c1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dobro=C5=88?= Date: Sat, 18 Nov 2023 20:09:22 +0100 Subject: [PATCH] Prevent redundant file scans --- src/fbt/Transform/FbtTransform/FbtTransform.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fbt/Transform/FbtTransform/FbtTransform.php b/src/fbt/Transform/FbtTransform/FbtTransform.php index f91c807..2ff6f76 100644 --- a/src/fbt/Transform/FbtTransform/FbtTransform.php +++ b/src/fbt/Transform/FbtTransform/FbtTransform.php @@ -94,7 +94,11 @@ public static function _fbtTraverse(Node $node) */ private static function initDefaultOptions(array $entrypoint) { - if (isset($entrypoint['file']) && file_exists($entrypoint['file'])) { + static $cache = []; + + if (isset($entrypoint['file']) && file_exists($entrypoint['file']) && ! in_array($entrypoint['file'], $cache)) { + $cache[] = $entrypoint['file']; + $comments = array_filter( token_get_all(file_get_contents($entrypoint['file'])), function ($entry) {