1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-17 21:10:39 +02:00

Minor optimizations in Menu

Use emplace_back when a new string is put into a vector.
Removed unused variables.
When searching section names, compare C++ string to C string, so we
don't need to construct a C++ string for the second string just for
the search.
This commit is contained in:
Maarten ter Huurne 2014-08-15 14:27:05 +02:00
parent 739a9463be
commit b202f1949a

View File

@ -120,10 +120,8 @@ void Menu::readSections(std::string parentDir)
if (dptr->d_name[0] == '.' || dptr->d_type != DT_DIR)
continue;
string filepath = parentDir + "/" + dptr->d_name;
if (find(sections.begin(), sections.end(), (string)dptr->d_name) == sections.end()) {
sections.push_back((string)dptr->d_name);
if (find(sections.begin(), sections.end(), dptr->d_name) == sections.end()) {
sections.emplace_back(dptr->d_name);
vector<Link*> ll;
links.push_back(ll);
}
@ -802,8 +800,7 @@ void Menu::readLinksOfSection(std::string path, std::vector<std::string> &linkfi
while ((dptr = readdir(dirp))) {
if (dptr->d_type != DT_REG) continue;
string filepath = path + "/" + dptr->d_name;
linkfiles.push_back(filepath);
linkfiles.emplace_back(path + "/" + dptr->d_name);
}
closedir(dirp);
@ -836,7 +833,6 @@ void Menu::readLinks() {
iLink = 0;
iFirstDispRow = 0;
string filepath;
for (uint i=0; i<links.size(); i++) {
links[i].clear();