Skip to content
Snippets Groups Projects
Commit 74d1a9ea authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #13235 from owncloud/cache-normalize-path

Cache results of `normalizePath`
parents 49ed2ebb 7e11ca06
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,8 @@ class Filesystem {
static private $usersSetup = array();
static private $normalizedPathCache = array();
/**
* classname which used for hooks handling
* used as signalclass in OC_Hooks::emit()
......@@ -713,6 +715,12 @@ class Filesystem {
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) {
$cacheKey = $path.'-'.-$stripTrailingSlash.'-'.$isAbsolutePath;
if(isset(self::$normalizedPathCache[$cacheKey])) {
return self::$normalizedPathCache[$cacheKey];
}
if ($path == '') {
return '/';
}
......@@ -756,7 +764,10 @@ class Filesystem {
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);
return $windows_drive_letter . $path;
$normalizedPath = $windows_drive_letter . $path;
self::$normalizedPathCache[$cacheKey] = $normalizedPath;
return $normalizedPath;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment