mirror of https://github.com/stella-emu/stella.git
Optimization of FSNode::getXXX string methods. They now return
'const string&', which saves a string c'tor call each time they're accessed. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2293 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
52cf172661
commit
115d560f87
|
@ -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);
|
assert(_realNode);
|
||||||
return _realNode->getDisplayName();
|
return _realNode->getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string FilesystemNode::getName() const
|
const string& FilesystemNode::getName() const
|
||||||
{
|
{
|
||||||
assert(_realNode);
|
assert(_realNode);
|
||||||
return _realNode->getName();
|
return _realNode->getName();
|
||||||
|
@ -122,7 +122,7 @@ FilesystemNode FilesystemNode::getParent() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string FilesystemNode::getPath() const
|
const string& FilesystemNode::getPath() const
|
||||||
{
|
{
|
||||||
assert(_realNode);
|
assert(_realNode);
|
||||||
return _realNode->getPath();
|
return _realNode->getPath();
|
||||||
|
|
|
@ -153,7 +153,7 @@ class FilesystemNode
|
||||||
*
|
*
|
||||||
* @return the display name
|
* @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
|
* Return a string representation of the name of the file. This is can be
|
||||||
|
@ -163,7 +163,7 @@ class FilesystemNode
|
||||||
*
|
*
|
||||||
* @return the file name
|
* @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().
|
* 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
|
* @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 '~'
|
* 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().
|
* @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.
|
* 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.
|
* @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().
|
* 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.
|
* Returns the 'path' of the current node, containing '~' and for archiving.
|
||||||
|
|
|
@ -59,9 +59,9 @@ class POSIXFilesystemNode : public AbstractFilesystemNode
|
||||||
POSIXFilesystemNode(const string& path, bool verify);
|
POSIXFilesystemNode(const string& path, bool verify);
|
||||||
|
|
||||||
bool exists() const { return access(_path.c_str(), F_OK) == 0; }
|
bool exists() const { return access(_path.c_str(), F_OK) == 0; }
|
||||||
string getDisplayName() const { return _displayName; }
|
const string& getDisplayName() const { return _displayName; }
|
||||||
string getName() const { return _displayName; }
|
const string& getName() const { return _displayName; }
|
||||||
string getPath() const { return _path; }
|
const string& getPath() const { return _path; }
|
||||||
string getRelativePath() const;
|
string getRelativePath() const;
|
||||||
bool isDirectory() const { return _isDirectory; }
|
bool isDirectory() const { return _isDirectory; }
|
||||||
bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
||||||
|
|
|
@ -92,9 +92,9 @@ class WindowsFilesystemNode : public AbstractFilesystemNode
|
||||||
WindowsFilesystemNode(const string& path);
|
WindowsFilesystemNode(const string& path);
|
||||||
|
|
||||||
bool exists() const { return _access(_path.c_str(), F_OK) == 0; }
|
bool exists() const { return _access(_path.c_str(), F_OK) == 0; }
|
||||||
string getDisplayName() const { return _displayName; }
|
const string& getDisplayName() const { return _displayName; }
|
||||||
string getName() const { return _displayName; }
|
const string& getName() const { return _displayName; }
|
||||||
string getPath() const { return _path; }
|
const string& getPath() const { return _path; }
|
||||||
string getRelativePath() const;
|
string getRelativePath() const;
|
||||||
bool isDirectory() const { return _isDirectory; }
|
bool isDirectory() const { return _isDirectory; }
|
||||||
bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }
|
bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }
|
||||||
|
|
Loading…
Reference in New Issue