diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-08 20:47:11 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-08 21:38:10 +0200 |
commit | 6af980c20c99e31629f283dae39161ece8a415fc (patch) | |
tree | 01e57f5cfeac2ed3a1dd7dcc812ac31bd9b500a4 | |
parent | d9d6876be9bbf32c39f676e3d6cbab85e57abd34 (diff) | |
download | nextcloud-server-6af980c20c99e31629f283dae39161ece8a415fc.tar.gz nextcloud-server-6af980c20c99e31629f283dae39161ece8a415fc.zip |
Add cache for getStorage and getInternalPath functions.
These are called for almost every file operation.
-rw-r--r-- | lib/filesystemview.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php index c8df59cf827..8aa7b49f413 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -40,6 +40,8 @@ class OC_FilesystemView { private $fakeRoot=''; + private $internal_path_cache=array(); + private $storage_cache=array(); public function __construct($root){ $this->fakeRoot=$root; @@ -84,7 +86,10 @@ class OC_FilesystemView { * @return bool */ public function getInternalPath($path){ - return OC_Filesystem::getInternalPath($this->getAbsolutePath($path)); + if (!isset($this->internal_path_cache[$path])) { + $this->internal_path_cache[$path] = OC_Filesystem::getInternalPath($this->getAbsolutePath($path)); + } + return $this->internal_path_cache[$path]; } /** * get the storage object for a path @@ -92,7 +97,10 @@ class OC_FilesystemView { * @return OC_Filestorage */ public function getStorage($path){ - return OC_Filesystem::getStorage($this->getAbsolutePath($path)); + if (!isset($this->storage_cache[$path])) { + $this->storage_cache[$path] = OC_Filesystem::getStorage($this->getAbsolutePath($path)); + } + return $this->storage_cache[$path]; } /** |