diff options
author | Robin Appelman <robin@icewind.nl> | 2018-08-16 18:24:10 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-08-16 18:24:56 +0200 |
commit | 95981810c05100f0439afe6d99973e0f1bd13d39 (patch) | |
tree | ec34b26707e530ec90a9947892a0365eceed0182 | |
parent | bcc1a53f05a8442ff1a8a5f06c585470aa44f521 (diff) | |
download | nextcloud-server-95981810c05100f0439afe6d99973e0f1bd13d39.tar.gz nextcloud-server-95981810c05100f0439afe6d99973e0f1bd13d39.zip |
remove double loop for detecting changed mounts
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index a6741652308..0b9501b4442 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -135,16 +135,19 @@ class UserMountCache implements IUserMountCache { * @return ICachedMountInfo[] */ private function findChangedMounts(array $newMounts, array $cachedMounts) { + $new = []; + foreach ($newMounts as $mount) { + $new[$mount->getRootId()] = $mount; + } $changed = []; - foreach ($newMounts as $newMount) { - foreach ($cachedMounts as $cachedMount) { + foreach ($cachedMounts as $cachedMount) { + $rootId = $cachedMount->getRootId(); + if (isset($new[$rootId])) { + $newMount = $new[$rootId]; if ( - $newMount->getRootId() === $cachedMount->getRootId() && - ( - $newMount->getMountPoint() !== $cachedMount->getMountPoint() || - $newMount->getStorageId() !== $cachedMount->getStorageId() || - $newMount->getMountId() !== $cachedMount->getMountId() - ) + $newMount->getMountPoint() !== $cachedMount->getMountPoint() || + $newMount->getStorageId() !== $cachedMount->getStorageId() || + $newMount->getMountId() !== $cachedMount->getMountId() ) { $changed[] = $newMount; } @@ -197,7 +200,7 @@ class UserMountCache implements IUserMountCache { } $mount_id = $row['mount_id']; if (!is_null($mount_id)) { - $mount_id = (int) $mount_id; + $mount_id = (int)$mount_id; } return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : ''); } |