From 4226aa761dd43e8515f4f4f6790f142fdd8b3927 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 3 Apr 2006 21:54:26 +0000 Subject: Fix AbstractFilesystemNode::wrap to not call (indirectly) getRoot, just to throw away the result immediately again (which (a) caused a slowdown and (b) a leak, both fixed now) svn-id: r21581 --- backends/fs/fs.cpp | 29 ++++++++++++++++++++++++++--- backends/fs/fs.h | 12 +++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/fs/fs.cpp b/backends/fs/fs.cpp index a3746575e6..60766cb073 100644 --- a/backends/fs/fs.cpp +++ b/backends/fs/fs.cpp @@ -38,11 +38,14 @@ void FSList::sort() { FilesystemNode AbstractFilesystemNode::wrap(AbstractFilesystemNode *node) { - FilesystemNode wrapper; - wrapper._realNode = node; + FilesystemNode wrapper(node); return wrapper; } +FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) { + _realNode = realNode; + _refCount = new int(1); +} FilesystemNode::FilesystemNode() { _realNode = getRoot(); @@ -56,7 +59,7 @@ FilesystemNode::FilesystemNode(const FilesystemNode &node) ++(*_refCount); } -FilesystemNode::FilesystemNode(const String &p) { +FilesystemNode::FilesystemNode(const Common::String &p) { _realNode = getNodeForPath(p); _refCount = new int(1); } @@ -92,3 +95,23 @@ FilesystemNode FilesystemNode::getParent() const { return AbstractFilesystemNode::wrap(node); } } + +Common::String FilesystemNode::displayName() const { + return _realNode->displayName(); +} + +bool FilesystemNode::isValid() const { + return _realNode->isValid(); +} + +bool FilesystemNode::isDirectory() const { + return _realNode->isDirectory(); +} + +Common::String FilesystemNode::path() const { + return _realNode->path(); +} + +FSList FilesystemNode::listDir(ListMode mode) const { + return _realNode->listDir(mode); +} diff --git a/backends/fs/fs.h b/backends/fs/fs.h index 6ad51762ca..7005707b16 100644 --- a/backends/fs/fs.h +++ b/backends/fs/fs.h @@ -165,6 +165,8 @@ private: AbstractFilesystemNode *_realNode; int *_refCount; + FilesystemNode(AbstractFilesystemNode *realNode); + /** * Returns a special node representing the FS root. The starting point for * any file system browsing. @@ -199,12 +201,12 @@ public: FilesystemNode getParent() const; - virtual String displayName() const { return _realNode->displayName(); } - virtual bool isValid() const { return _realNode->isValid(); } - virtual bool isDirectory() const { return _realNode->isDirectory(); } - virtual String path() const { return _realNode->path(); } + virtual String displayName() const; + virtual bool isValid() const; + virtual bool isDirectory() const; + virtual String path() const; - virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const { return _realNode->listDir(mode); } + virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const; protected: void decRefCount(); -- cgit v1.2.3