Skip to content

Commit a65e280

Browse files
committed
perf: Replace getById call with getFistNodeByid
We only need the first node anyway and getFirstNodeById is quite a bit faster in many cases. Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 15386c1 commit a65e280

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/Service/NotesService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ private function getCustomExtension(string $userId) {
210210
* @throws NoteDoesNotExistException
211211
*/
212212
private static function getFileById(string $customExtension, Folder $folder, int $id) : File {
213-
$file = $folder->getById($id);
213+
$file = $folder->getFirstNodeById($id);
214214

215-
if (!array_key_exists(0, $file) || !($file[0] instanceof File) || !self::isNote($file[0], $customExtension)) {
215+
if (!($file instanceof File) || !self::isNote($file, $customExtension)) {
216216
throw new NoteDoesNotExistException();
217217
}
218-
return $file[0];
218+
return $file;
219219
}
220220

221221
/**

0 commit comments

Comments
 (0)