Index: tools/gn/label.h |
diff --git a/tools/gn/label.h b/tools/gn/label.h |
index 88336eafa6d2540132547388173a384d14d606c6..172cbbe511ad034ff06f5a173e6f32d27ebd331d 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_.compare(other.dir_)) |
brettw
2015/11/20 21:44:31
You didn't use tie here to avoid the double-checki
jsbell
2015/11/20 22:04:27
Correct. I assumed (based on the TODO) that there
|
+ return c == -1; |
+ if (int c = name_.compare(other.name_)) |
+ return c == -1; |
+ if (int c = toolchain_dir_.compare(other.toolchain_dir_)) |
brettw
2015/11/20 22:17:57
You can use value() on the dir names to get the st
|
+ return c == -1; |
return toolchain_name_ < other.toolchain_name_; |
} |