diff --git a/webapp/src/Service/DOMJudgeService.php b/webapp/src/Service/DOMJudgeService.php index 5101285bf8..1d9cb19f25 100644 --- a/webapp/src/Service/DOMJudgeService.php +++ b/webapp/src/Service/DOMJudgeService.php @@ -1342,6 +1342,10 @@ public function apiRelativeUrl(string $route, array $params = []): string return substr($route, strlen($apiRootRoute) + $offset); } + + /** @var array */ + private static array $assetFiles = []; + /** * Get asset files in the given directory with the given extension * @@ -1349,9 +1353,13 @@ public function apiRelativeUrl(string $route, array $params = []): string */ public function getAssetFiles(string $path): array { + if (isset(self::$assetFiles[$path])) { + return self::$assetFiles[$path]; + } + $customDir = sprintf('%s/public/%s', $this->params->get('kernel.project_dir'), $path); if (!is_dir($customDir)) { - return []; + return self::$assetFiles[$path] = []; } $results = []; @@ -1363,7 +1371,7 @@ public function getAssetFiles(string $path): array } } - return $results; + return self::$assetFiles[$path] = $results; } /**