Add cache for getStorage and getInternalPath functions.
These are called for almost every file operation.
This commit is contained in:
parent
e728635c8a
commit
598a090db4
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
class OC_FilesystemView {
|
class OC_FilesystemView {
|
||||||
private $fakeRoot='';
|
private $fakeRoot='';
|
||||||
|
private $internal_path_cache=array();
|
||||||
|
private $storage_cache=array();
|
||||||
|
|
||||||
public function __construct($root){
|
public function __construct($root){
|
||||||
$this->fakeRoot=$root;
|
$this->fakeRoot=$root;
|
||||||
|
@ -67,7 +69,10 @@ class OC_FilesystemView {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getInternalPath($path){
|
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
|
* get the storage object for a path
|
||||||
|
@ -75,7 +80,10 @@ class OC_FilesystemView {
|
||||||
* @return OC_Filestorage
|
* @return OC_Filestorage
|
||||||
*/
|
*/
|
||||||
public function getStorage($path){
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue