From 5020d9b05ab1aee214503935b9b8b4d4c5ef3522 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 27 Jun 2024 14:47:48 +0200 Subject: [PATCH] perf: optimize WorkspaceService::getFile Signed-off-by: Robin Appelman --- lib/Service/WorkspaceService.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php index 087f960941a..8bec036a202 100644 --- a/lib/Service/WorkspaceService.php +++ b/lib/Service/WorkspaceService.php @@ -29,15 +29,13 @@ public function __construct(IL10N $l10n) { public function getFile(Folder $folder): ?File { foreach ($this->getSupportedFilenames() as $filename) { - if ($folder->nodeExists($filename)) { - try { - $file = $folder->get($filename); - if ($file instanceof File) { - return $file; - } - } catch (NotFoundException|StorageInvalidException) { - return null; + try { + $file = $folder->get($filename); + if ($file instanceof File) { + return $file; } + } catch (NotFoundException|StorageInvalidException) { + continue; } } return null;