1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-26 05:07:42 +02:00

Have Menu::readLinks() sort using orderLinks()

Previously, it sorted before Link instances were created. Using
readLinks() ensures consistency and it might be more efficient if
a significant number of link files are rejected.

Also modernized the body of orderLinks() and removed unnecessary
special case for 1-link sections.
This commit is contained in:
Maarten ter Huurne 2014-08-17 21:52:21 +02:00
parent 3694deecf6
commit e39447ee64

View File

@ -822,13 +822,13 @@ static bool compare_links(Link *a, Link *b)
void Menu::orderLinks()
{
for (std::vector< std::vector<Link *> >::iterator section = links.begin();
section < links.end(); section++)
if (section->size() > 1)
std::sort(section->begin(), section->end(), compare_links);
for (auto& section : links) {
sort(section.begin(), section.end(), compare_links);
}
}
void Menu::readLinks() {
void Menu::readLinks()
{
vector<string> linkfiles;
iLink = 0;
@ -846,7 +846,6 @@ void Menu::readLinks() {
readLinksOfSection(GMenu2X::getHome() + "/sections/"
+ sections[correct], linkfiles);
sort(linkfiles.begin(), linkfiles.end(),case_less());
for (auto const& linkfile : linkfiles) {
// Check whether the link file could be deleted.
bool deletable = access(parentDir(linkfile).c_str(), W_OK) == 0;
@ -859,6 +858,8 @@ void Menu::readLinks() {
delete link;
}
}
orderLinks();
}
void Menu::renameSection(int index, const string &name) {