diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index c5ff53c16..8fb46391c 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -86,14 +86,14 @@ bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, bool hidden) con } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string FilesystemNode::getDisplayName() const +const string& FilesystemNode::getDisplayName() const { assert(_realNode); return _realNode->getDisplayName(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string FilesystemNode::getName() const +const string& FilesystemNode::getName() const { assert(_realNode); return _realNode->getName(); @@ -122,7 +122,7 @@ FilesystemNode FilesystemNode::getParent() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string FilesystemNode::getPath() const +const string& FilesystemNode::getPath() const { assert(_realNode); return _realNode->getPath(); diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index e6396a6aa..ab8e56ac8 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -153,7 +153,7 @@ class FilesystemNode * * @return the display name */ - virtual string getDisplayName() const; + virtual const string& getDisplayName() const; /** * Return a string representation of the name of the file. This is can be @@ -163,7 +163,7 @@ class FilesystemNode * * @return the file name */ - virtual string getName() const; + virtual const string& getName() const; /** * Return a string representation of the file which can be passed to fopen(). @@ -175,7 +175,7 @@ class FilesystemNode * * @return the 'path' represented by this filesystem node */ - virtual string getPath() const; + virtual const string& getPath() const; /** * Return a string representation of the file which contains the '~' @@ -288,7 +288,7 @@ class AbstractFilesystemNode * * @note By default, this method returns the value of getName(). */ - virtual string getDisplayName() const { return getName(); } + virtual const string& getDisplayName() const { return getName(); } /** * Returns the last component of the path pointed by this FilesystemNode. @@ -299,12 +299,12 @@ class AbstractFilesystemNode * * @note This method is very architecture dependent, please check the concrete implementation for more information. */ - virtual string getName() const = 0; + virtual const string& getName() const = 0; /** * Returns the 'path' of the current node, usable in fopen(). */ - virtual string getPath() const = 0; + virtual const string& getPath() const = 0; /** * Returns the 'path' of the current node, containing '~' and for archiving. diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index f6f1e5c63..debe301ab 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -59,9 +59,9 @@ class POSIXFilesystemNode : public AbstractFilesystemNode POSIXFilesystemNode(const string& path, bool verify); bool exists() const { return access(_path.c_str(), F_OK) == 0; } - string getDisplayName() const { return _displayName; } - string getName() const { return _displayName; } - string getPath() const { return _path; } + const string& getDisplayName() const { return _displayName; } + const string& getName() const { return _displayName; } + const string& getPath() const { return _path; } string getRelativePath() const; bool isDirectory() const { return _isDirectory; } bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } diff --git a/src/win32/FSNodeWin32.cxx b/src/win32/FSNodeWin32.cxx index 57853666a..08749feee 100644 --- a/src/win32/FSNodeWin32.cxx +++ b/src/win32/FSNodeWin32.cxx @@ -92,9 +92,9 @@ class WindowsFilesystemNode : public AbstractFilesystemNode WindowsFilesystemNode(const string& path); bool exists() const { return _access(_path.c_str(), F_OK) == 0; } - string getDisplayName() const { return _displayName; } - string getName() const { return _displayName; } - string getPath() const { return _path; } + const string& getDisplayName() const { return _displayName; } + const string& getName() const { return _displayName; } + const string& getPath() const { return _path; } string getRelativePath() const; bool isDirectory() const { return _isDirectory; } bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }