Skip to content

Commit 7f36f1e

Browse files
committed
Cache the results of getAssetFiles
Fix the disk backlog during scoreboard pictures rendering. Signed-off-by: cubercsl <[email protected]>
1 parent 74a851b commit 7f36f1e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

webapp/src/Service/DOMJudgeService.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,16 +1340,22 @@ public function apiRelativeUrl(string $route, array $params = []): string
13401340
return substr($route, strlen($apiRootRoute) + $offset);
13411341
}
13421342

1343+
private static array $assetFiles = [];
1344+
13431345
/**
13441346
* Get asset files in the given directory with the given extension
13451347
*
13461348
* @return string[]
13471349
*/
13481350
public function getAssetFiles(string $path): array
13491351
{
1352+
if(isset(self::$assetFiles[$path])) {
1353+
return self::$assetFiles[$path];
1354+
}
1355+
13501356
$customDir = sprintf('%s/public/%s', $this->params->get('kernel.project_dir'), $path);
13511357
if (!is_dir($customDir)) {
1352-
return [];
1358+
return self::$assetFiles[$path] = [];
13531359
}
13541360

13551361
$results = [];
@@ -1361,7 +1367,7 @@ public function getAssetFiles(string $path): array
13611367
}
13621368
}
13631369

1364-
return $results;
1370+
return self::$assetFiles[$path] = $results;
13651371
}
13661372

13671373
/**

0 commit comments

Comments
 (0)