diff --git a/src/common/Array.hxx b/src/common/Array.hxx index 691424432..6e55d5bd7 100644 --- a/src/common/Array.hxx +++ b/src/common/Array.hxx @@ -131,7 +131,8 @@ class Array return *this; } - unsigned int size() const { return _size; } + unsigned int size() const { return _size; } + unsigned int capacity() const { return _capacity; } void clear() { diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 3ce917cc7..b88b5d088 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -72,11 +72,11 @@ bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, bool hidden) con return false; AbstractFSList tmp; + tmp.reserve(fslist.capacity()); if (!_realNode->getChildren(tmp, mode, hidden)) return false; - fslist.clear(); for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) { fslist.push_back(FilesystemNode(*i)); diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 63bed1ece..09099303b 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -168,6 +168,7 @@ void BrowserDialog::updateListing() // Read in the data from the file system FSList content; + content.reserve(2048); _node.getChildren(content, _mode); // Add '[..]' to indicate previous folder diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 38bb3bdd2..2de240e00 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -345,7 +345,7 @@ void LauncherDialog::loadDirListing() return; FSList files; - files.reserve(1024); + files.reserve(2048); myCurrentNode.getChildren(files, FilesystemNode::kListAll); // Add '[..]' to indicate previous folder diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index 4c140d99b..c4e2f46d5 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -127,6 +127,7 @@ void RomAuditDialog::auditRoms() FilesystemNode node(auditPath); FSList files; + files.reserve(2048); node.getChildren(files, FilesystemNode::kListFilesOnly); // Create a progress dialog box to show the progress of processing