summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-01-10 16:32:09 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-01-10 16:32:09 +0100
commit74d1a9ea3d5526e98a3febd13653917a2970f9e0 (patch)
tree2a02f2c992c6128f1feaabf359e93680beec9bf8
parent49ed2ebb2c347627c3e4c0c462c6215cfe11d665 (diff)
parent7e11ca06f69e3c6b5b21365232297259930548fe (diff)
downloadnextcloud-server-74d1a9ea3d5526e98a3febd13653917a2970f9e0.tar.gz
nextcloud-server-74d1a9ea3d5526e98a3febd13653917a2970f9e0.zip
Merge pull request #13235 from owncloud/cache-normalize-path
Cache results of `normalizePath`
-rw-r--r--lib/private/files/filesystem.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index ed2be59c092..bc43eb5d1ce 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -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;
}
/**