From 22d0ea3b3a97b195ffeb008cd1efdb3bfb130912 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 19 Jun 2026 13:06:53 +0200 Subject: [PATCH] perf: Avoid sorting an already sorted array Improve performance a bit as this is in the hotpath and take ~2s in prod. Signed-off-by: Carl Schwan --- lib/private/Files/Mount/Manager.php | 5 ----- lib/private/Files/Node/LazyFolder.php | 2 +- lib/private/Files/Node/Root.php | 4 ---- lib/private/Files/View.php | 4 ---- lib/public/Files/IRootFolder.php | 2 +- lib/public/Files/Mount/IMountManager.php | 2 +- 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index 6923eb7aa6664..90d714ba982e7 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -111,11 +111,6 @@ public function find(string $path): IMountPoint { throw new NotFoundException('No mount for path ' . $path . ' existing mounts (' . count($this->mounts) . '): ' . implode(',', array_keys($this->mounts))); } - /** - * Find all mounts in $path - * - * @return IMountPoint[] - */ #[\Override] public function findIn(string $path): array { $this->setupManager->setupForPath($path, true); diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 96b4cecd3d233..26b7eff4031c5 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -110,7 +110,7 @@ public function getMount(string $mountPoint): IMountPoint { } /** - * @return IMountPoint[] + * @return list */ public function getMountsIn(string $mountPoint): array { return $this->__call(__FUNCTION__, func_get_args()); diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 095db425ed606..74e24664a5c99 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -136,10 +136,6 @@ public function getMount(string $mountPoint): IMountPoint { return $this->mountManager->find($mountPoint); } - /** - * @param string $mountPoint - * @return IMountPoint[] - */ #[\Override] public function getMountsIn(string $mountPoint): array { return $this->mountManager->findIn($mountPoint); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 468ad73acec52..77472b5474a04 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1570,10 +1570,6 @@ public function getDirectoryContent(string $directory, ?string $mimeTypeFilter = //add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders $mounts = Filesystem::getMountManager()->findIn($path); - // make sure nested mounts are sorted after their parent mounts - // otherwise doesn't propagate the etag across storage boundaries correctly - usort($mounts, static fn (IMountPoint $a, IMountPoint $b): int => $a->getMountPoint() <=> $b->getMountPoint()); - $dirLength = strlen($path); foreach ($mounts as $mount) { $mountPoint = $mount->getMountPoint(); diff --git a/lib/public/Files/IRootFolder.php b/lib/public/Files/IRootFolder.php index 870b2dceb1a9c..e30d04c36ab51 100644 --- a/lib/public/Files/IRootFolder.php +++ b/lib/public/Files/IRootFolder.php @@ -62,7 +62,7 @@ public function getByIdInPath(int $id, string $path); public function getFirstNodeByIdInPath(int $id, string $path): ?Node; /** - * @return IMountPoint[] + * @return list * * @since 28.0.0 */ diff --git a/lib/public/Files/Mount/IMountManager.php b/lib/public/Files/Mount/IMountManager.php index 9cdf546aea22c..73dc85cbecd70 100644 --- a/lib/public/Files/Mount/IMountManager.php +++ b/lib/public/Files/Mount/IMountManager.php @@ -56,7 +56,7 @@ public function find(string $path): ?IMountPoint; * Find all mounts in $path * * @param string $path - * @return IMountPoint[] + * @return list Returns a sorted list of mount point * @since 8.2.0 */ public function findIn(string $path): array;