perf(normalization): Optimize path normalization

Signed-off-by: Carl Schwan <carlschwan@kde.org>
(cherry picked from commit 09a1ca3981)
This commit is contained in:
Carl Schwan 2026-01-15 15:56:13 +01:00
parent 47524649c7
commit 6bc805ad39
No known key found for this signature in database
GPG key ID: 02325448204E452A

View file

@ -7,10 +7,8 @@
*/
namespace OC\Files;
use OC\Files\Mount\MountPoint;
use OC\Files\Storage\StorageFactory;
use OC\User\NoUserException;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\FilesystemTornDownEvent;
use OCP\Files\Mount\IMountManager;
@ -28,8 +26,6 @@ class Filesystem {
private static ?View $defaultInstance = null;
private static ?CappedMemoryCache $normalizedPathCache = null;
private static ?FilenameValidator $validator = null;
/**
@ -607,16 +603,6 @@ class Filesystem {
return '/';
}
if (is_null(self::$normalizedPathCache)) {
self::$normalizedPathCache = new CappedMemoryCache(2048);
}
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
if ($cacheKey && isset(self::$normalizedPathCache[$cacheKey])) {
return self::$normalizedPathCache[$cacheKey];
}
//normalize unicode if possible
if (!$keepUnicode) {
$path = \OC_Util::normalizeUnicode($path);
@ -642,8 +628,6 @@ class Filesystem {
$path = rtrim($path, '/');
}
self::$normalizedPathCache[$cacheKey] = $path;
return $path;
}