From 67fda4ece59b3b869520390314f92f17fdfe22f8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 7 Apr 2006 11:47:58 +0000 Subject: 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 --- backends/fs/fs.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'backends/fs') 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) -- cgit v1.2.3