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
185185        p = path.rfind("/", p - 1);
186186    }
187187
188    if (p == string::npos || path.compare(0, 1, "/") != 0 || path.length() < 2) {
188    if (p == string::npos || path.length() < 2 || path[0] != '/') {
189189        quit();
190190    } else {
191191        selected = 0;
src/menu.cpp
545545                !icon_used && section<links.end(); section++)
546546        for (vector<Link*>::iterator link = section->begin();
547547                    !icon_used && link<section->end(); link++)
548            icon_used = !iconpath.compare((*link)->getIconPath());
548            icon_used = iconpath == (*link)->getIconPath();
549549
550550    if (!icon_used)
551551      gmenu2x->sc.del(iconpath);
...... 
694694            pos = metadata.rfind('.');
695695            metadata = metadata.substr(pos + 1);
696696
697            if (!metadata.compare(PLATFORM) || !metadata.compare("all")) {
697            if (metadata == PLATFORM || metadata == "all") {
698698                has_metadata = true;
699699                break;
700700            }
src/selector.cpp
176176            case InputManager::LEFT:
177177                if (link->getSelectorBrowser()) {
178178                    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] != '/') {
180180                        close = true;
181181                        result = false;
182182                    } else {

Archive Download the corresponding diff file



interactive