diff options
author | Robin Appelman <robin@icewind.nl> | 2018-08-16 19:24:10 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-08-27 17:19:50 +0300 |
commit | 67ae310693f6457bdbbdfe414e2ed5eae23f1124 (patch) | |
tree | 73125fa3fba4425c4637c957bf0ea766e899533e /lib | |
parent | 1769029910b3dc47dd435214b33e9136d02b12e6 (diff) |
remove double loop for detecting changed mounts
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-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 255314c4e83..095a0df7e0c 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -136,16 +136,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; } @@ -198,7 +201,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'] : ''); } |