Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Unified Diff: tools/gn/label.h

Issue 1461623006: Use simplify operator< implementations in tools/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix string compare checks Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/location.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/label.h
diff --git a/tools/gn/label.h b/tools/gn/label.h
index 88336eafa6d2540132547388173a384d14d606c6..33cac56ade9d94d6754d42a566658cfbbba1252c 100644
--- a/tools/gn/label.h
+++ b/tools/gn/label.h
@@ -71,14 +71,12 @@ class Label {
return !operator==(other);
}
bool operator<(const Label& other) const {
- // TODO(brettw) could be optimized to avoid an extra full string check
- // (one for operator==, one for <).
- if (dir_ != other.dir_)
- return dir_ < other.dir_;
- if (name_ != other.name_)
- return name_ < other.name_;
- if (toolchain_dir_ != other.toolchain_dir_)
- return toolchain_dir_ < other.toolchain_dir_;
+ if (int c = dir_.value().compare(other.dir_.value()))
+ return c < 0;
+ if (int c = name_.compare(other.name_))
+ return c < 0;
+ if (int c = toolchain_dir_.value().compare(other.toolchain_dir_.value()))
+ return c < 0;
return toolchain_name_ < other.toolchain_name_;
}
« no previous file with comments | « no previous file | tools/gn/location.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698