From 85b072ca43cf9286a592fa9f8ef738e420e32cdd Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Thu, 14 Aug 2014 05:02:24 +0200 Subject: [PATCH] Removed FileLister::at In the STL, 'at' will perform range checking while operator[] will not. Since GMenu2X doesn't use exceptions, range checking is not possible, so 'at' and operator[] were identical. --- src/browsedialog.cpp | 2 +- src/filelister.cpp | 11 ++--------- src/filelister.h | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/browsedialog.cpp b/src/browsedialog.cpp index 5d9793d..c544da1 100644 --- a/src/browsedialog.cpp +++ b/src/browsedialog.cpp @@ -200,7 +200,7 @@ void BrowseDialog::directoryEnter() path += "/"; } - setPath(path + fl.at(selected)); + setPath(path + fl[selected]); selected = 0; } diff --git a/src/filelister.cpp b/src/filelister.cpp index adfdafd..0364c45 100644 --- a/src/filelister.cpp +++ b/src/filelister.cpp @@ -166,15 +166,8 @@ void FileLister::browse(const string& path, bool clean) string FileLister::operator[](uint x) { - return at(x); -} - -string FileLister::at(uint x) -{ - if (x < directories.size()) - return directories[x]; - else - return files[x-directories.size()]; + const auto dirCount = directories.size(); + return x < dirCount ? directories[x] : files[x - dirCount]; } void FileLister::insertFile(const string &file) { diff --git a/src/filelister.h b/src/filelister.h index 7cedb98..5b7c692 100644 --- a/src/filelister.h +++ b/src/filelister.h @@ -40,7 +40,6 @@ public: unsigned int fileCount() { return files.size(); } std::string operator[](unsigned int); - std::string at(unsigned int); bool isFile(unsigned int x) { return x >= directories.size(); } bool isDirectory(unsigned int x) { return x < directories.size(); }