mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 11:03:44 +02:00
Don't use string::compare if there are better alternatives
When comparing full strings, operator== will do nicely. When comparing the first char, "s[0] == c" is more efficient if we know the string cannot be empty.
This commit is contained in:
parent
6e8491abee
commit
739a9463be
@ -185,7 +185,7 @@ void BrowseDialog::directoryUp()
|
|||||||
p = path.rfind("/", p - 1);
|
p = path.rfind("/", p - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == string::npos || path.compare(0, 1, "/") != 0 || path.length() < 2) {
|
if (p == string::npos || path.length() < 2 || path[0] != '/') {
|
||||||
quit();
|
quit();
|
||||||
} else {
|
} else {
|
||||||
selected = 0;
|
selected = 0;
|
||||||
|
@ -545,7 +545,7 @@ void Menu::deleteSelectedLink()
|
|||||||
!icon_used && section<links.end(); section++)
|
!icon_used && section<links.end(); section++)
|
||||||
for (vector<Link*>::iterator link = section->begin();
|
for (vector<Link*>::iterator link = section->begin();
|
||||||
!icon_used && link<section->end(); link++)
|
!icon_used && link<section->end(); link++)
|
||||||
icon_used = !iconpath.compare((*link)->getIconPath());
|
icon_used = iconpath == (*link)->getIconPath();
|
||||||
|
|
||||||
if (!icon_used)
|
if (!icon_used)
|
||||||
gmenu2x->sc.del(iconpath);
|
gmenu2x->sc.del(iconpath);
|
||||||
@ -694,7 +694,7 @@ void Menu::openPackage(std::string path, bool order)
|
|||||||
pos = metadata.rfind('.');
|
pos = metadata.rfind('.');
|
||||||
metadata = metadata.substr(pos + 1);
|
metadata = metadata.substr(pos + 1);
|
||||||
|
|
||||||
if (!metadata.compare(PLATFORM) || !metadata.compare("all")) {
|
if (metadata == PLATFORM || metadata == "all") {
|
||||||
has_metadata = true;
|
has_metadata = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ int Selector::exec(int startSelection) {
|
|||||||
case InputManager::LEFT:
|
case InputManager::LEFT:
|
||||||
if (link->getSelectorBrowser()) {
|
if (link->getSelectorBrowser()) {
|
||||||
string::size_type p = dir.rfind("/", dir.size()-2);
|
string::size_type p = dir.rfind("/", dir.size()-2);
|
||||||
if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) {
|
if (p==string::npos || dir.length() < 2 || dir[0] != '/') {
|
||||||
close = true;
|
close = true;
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user