]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add cache for getStorage and getInternalPath functions.
authorBart Visscher <bartv@thisnet.nl>
Fri, 8 Jun 2012 18:47:11 +0000 (20:47 +0200)
committerBart Visscher <bartv@thisnet.nl>
Fri, 8 Jun 2012 19:38:10 +0000 (21:38 +0200)
These are called for almost every file operation.

lib/filesystemview.php

index c8df59cf8272164552cdc05e9cd1d1a38763f36a..8aa7b49f4137975d279c799ace374f60bcf87bdc 100644 (file)
@@ -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];
        }
 
        /**