Date: | 2014-08-15 14:19:17 (9 years 7 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 739a9463be1a4543ce0f5b1d8bf088ce4f437157 |
Message: | 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. |
Files: |
src/browsedialog.cpp (1 diff) src/menu.cpp (2 diffs) src/selector.cpp (1 diff) |
Change Details
src/browsedialog.cpp | ||
---|---|---|
185 | 185 | p = path.rfind("/", p - 1); |
186 | 186 | } |
187 | 187 | |
188 | if (p == string::npos || path.compare(0, 1, "/") != 0 || path.length() < 2) { | |
188 | if (p == string::npos || path.length() < 2 || path[0] != '/') { | |
189 | 189 | quit(); |
190 | 190 | } else { |
191 | 191 | selected = 0; |
src/menu.cpp | ||
---|---|---|
545 | 545 | !icon_used && section<links.end(); section++) |
546 | 546 | for (vector<Link*>::iterator link = section->begin(); |
547 | 547 | !icon_used && link<section->end(); link++) |
548 | icon_used = !iconpath.compare((*link)->getIconPath()); | |
548 | icon_used = iconpath == (*link)->getIconPath(); | |
549 | 549 | |
550 | 550 | if (!icon_used) |
551 | 551 | gmenu2x->sc.del(iconpath); |
... | ... | |
694 | 694 | pos = metadata.rfind('.'); |
695 | 695 | metadata = metadata.substr(pos + 1); |
696 | 696 | |
697 | if (!metadata.compare(PLATFORM) || !metadata.compare("all")) { | |
697 | if (metadata == PLATFORM || metadata == "all") { | |
698 | 698 | has_metadata = true; |
699 | 699 | break; |
700 | 700 | } |
src/selector.cpp | ||
---|---|---|
176 | 176 | case InputManager::LEFT: |
177 | 177 | if (link->getSelectorBrowser()) { |
178 | 178 | string::size_type p = dir.rfind("/", dir.size()-2); |
179 | if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) { | |
179 | if (p==string::npos || dir.length() < 2 || dir[0] != '/') { | |
180 | 180 | close = true; |
181 | 181 | result = false; |
182 | 182 | } else { |
Branches:
install_locations
master
opkrun
packages