Cache the $foundMountPointLength

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-03-26 16:47:46 +02:00
parent 003c624596
commit e48d4c4aad
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 3 additions and 1 deletions

View File

@ -79,9 +79,11 @@ class Manager implements IMountManager {
\OC_Hook::emit('OC_Filesystem', 'get_mountpoint', ['path' => $path]);
$foundMountPoint = '';
$mountPoints = array_keys($this->mounts);
$foundMountPointLength = 0;
foreach ($mountPoints as $mountpoint) {
if (strpos($path, $mountpoint) === 0 && \strlen($mountpoint) > \strlen($foundMountPoint)) {
if (strpos($path, $mountpoint) === 0 && \strlen($mountpoint) > $foundMountPointLength) {
$foundMountPoint = $mountpoint;
$foundMountPointLength = \strlen($foundMountPoint);
}
}