aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2006-04-03 21:54:26 +0000
committerMax Horn2006-04-03 21:54:26 +0000
commit4226aa761dd43e8515f4f4f6790f142fdd8b3927 (patch)
tree62d3312ed578e3d3b88c2372682361cbdb957e32 /backends
parent5595ec568097b86a72b26ada55507426c254f853 (diff)
downloadscummvm-rg350-4226aa761dd43e8515f4f4f6790f142fdd8b3927.tar.gz
scummvm-rg350-4226aa761dd43e8515f4f4f6790f142fdd8b3927.tar.bz2
scummvm-rg350-4226aa761dd43e8515f4f4f6790f142fdd8b3927.zip
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
Diffstat (limited to 'backends')
-rw-r--r--backends/fs/fs.cpp29
-rw-r--r--backends/fs/fs.h12
2 files changed, 33 insertions, 8 deletions
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();