diff options
author | Max Horn | 2006-04-07 11:47:58 +0000 |
---|---|---|
committer | Max Horn | 2006-04-07 11:47:58 +0000 |
commit | 67fda4ece59b3b869520390314f92f17fdfe22f8 (patch) | |
tree | d6907f101f6e165601cab53b89fa5da7d9e7168a /backends | |
parent | 00a4ca02245b03fa7e860c9d032133fbf424e2f5 (diff) | |
download | scummvm-rg350-67fda4ece59b3b869520390314f92f17fdfe22f8.tar.gz scummvm-rg350-67fda4ece59b3b869520390314f92f17fdfe22f8.tar.bz2 scummvm-rg350-67fda4ece59b3b869520390314f92f17fdfe22f8.zip |
Cache the root node (cause a major speedup on OSX, since by far the slowes part in the FS code over here is the getcwd call in getRoot() )
svn-id: r21667
Diffstat (limited to 'backends')
-rw-r--r-- | backends/fs/fs.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/backends/fs/fs.cpp b/backends/fs/fs.cpp index ecb8f50aab..445bea8efe 100644 --- a/backends/fs/fs.cpp +++ b/backends/fs/fs.cpp @@ -24,6 +24,10 @@ #include "backends/fs/fs.h" #include "common/util.h" + +static AbstractFilesystemNode *_rootNode = 0; +static int *_rootRefCount = 0; + FilesystemNode AbstractFilesystemNode::wrap(AbstractFilesystemNode *node) { FilesystemNode wrapper(node); return wrapper; @@ -35,8 +39,13 @@ FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) { } FilesystemNode::FilesystemNode() { - _realNode = getRoot(); - _refCount = new int(1); + if (_rootNode == 0) { + _rootNode = getRoot(); + _rootRefCount = new int(1); + } + _realNode = _rootNode; + _refCount = _rootRefCount; + ++(*_refCount); } FilesystemNode::FilesystemNode(const FilesystemNode &node) |