| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_GN_LABEL_H_ | 5 #ifndef TOOLS_GN_LABEL_H_ |
| 6 #define TOOLS_GN_LABEL_H_ | 6 #define TOOLS_GN_LABEL_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "tools/gn/source_dir.h" | 9 #include "tools/gn/source_dir.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 bool operator==(const Label& other) const { | 65 bool operator==(const Label& other) const { |
| 66 return name_ == other.name_ && dir_ == other.dir_ && | 66 return name_ == other.name_ && dir_ == other.dir_ && |
| 67 toolchain_dir_ == other.toolchain_dir_ && | 67 toolchain_dir_ == other.toolchain_dir_ && |
| 68 toolchain_name_ == other.toolchain_name_; | 68 toolchain_name_ == other.toolchain_name_; |
| 69 } | 69 } |
| 70 bool operator!=(const Label& other) const { | 70 bool operator!=(const Label& other) const { |
| 71 return !operator==(other); | 71 return !operator==(other); |
| 72 } | 72 } |
| 73 bool operator<(const Label& other) const { | 73 bool operator<(const Label& other) const { |
| 74 // TODO(brettw) could be optimized to avoid an extra full string check | 74 if (int c = dir_.value().compare(other.dir_.value())) |
| 75 // (one for operator==, one for <). | 75 return c < 0; |
| 76 if (dir_ != other.dir_) | 76 if (int c = name_.compare(other.name_)) |
| 77 return dir_ < other.dir_; | 77 return c < 0; |
| 78 if (name_ != other.name_) | 78 if (int c = toolchain_dir_.value().compare(other.toolchain_dir_.value())) |
| 79 return name_ < other.name_; | 79 return c < 0; |
| 80 if (toolchain_dir_ != other.toolchain_dir_) | |
| 81 return toolchain_dir_ < other.toolchain_dir_; | |
| 82 return toolchain_name_ < other.toolchain_name_; | 80 return toolchain_name_ < other.toolchain_name_; |
| 83 } | 81 } |
| 84 | 82 |
| 85 void swap(Label& other) { | 83 void swap(Label& other) { |
| 86 dir_.swap(other.dir_); | 84 dir_.swap(other.dir_); |
| 87 name_.swap(other.name_); | 85 name_.swap(other.name_); |
| 88 toolchain_dir_.swap(other.toolchain_dir_); | 86 toolchain_dir_.swap(other.toolchain_dir_); |
| 89 toolchain_name_.swap(other.toolchain_name_); | 87 toolchain_name_.swap(other.toolchain_name_); |
| 90 } | 88 } |
| 91 | 89 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 116 } | 114 } |
| 117 }; | 115 }; |
| 118 | 116 |
| 119 } // namespace BASE_HASH_NAMESPACE | 117 } // namespace BASE_HASH_NAMESPACE |
| 120 | 118 |
| 121 inline void swap(Label& lhs, Label& rhs) { | 119 inline void swap(Label& lhs, Label& rhs) { |
| 122 lhs.swap(rhs); | 120 lhs.swap(rhs); |
| 123 } | 121 } |
| 124 | 122 |
| 125 #endif // TOOLS_GN_LABEL_H_ | 123 #endif // TOOLS_GN_LABEL_H_ |
| OLD | NEW |