Chromium Code Reviews| Index: tools/gn/parse_tree.cc |
| diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc |
| index d22adca5c4b5f2d380d1f7167a769e1ec6bb985c..a8ec4ae92c10310be73ab3731f3e1b92917f1020 100644 |
| --- a/tools/gn/parse_tree.cc |
| +++ b/tools/gn/parse_tree.cc |
| @@ -16,6 +16,26 @@ |
| namespace { |
| +enum DepsCategory { |
| + kDepsCategoryLocal = 0, |
|
tfarina
2015/12/02 20:19:32
my understanding from the style-guide is that this
scottmg
2015/12/02 22:12:12
nit; Drop the " = N" since it's just for ordering
sdefresne
2015/12/03 09:30:00
Done both (dropped = N, used ALL_CAPS).
|
| + kDepsCategoryRelative = 1, |
| + kDepsCategoryAbsolute = 2, |
| + kDepsCategoryOther = 3, |
| +}; |
| + |
| +DepsCategory GetDepsCategory(base::StringPiece deps) { |
|
tfarina
2015/12/02 20:19:32
is it more recommended to pass it by value rather
sdefresne
2015/12/03 09:30:00
base/strings/string_piece.h recommends passing by
|
| + if (deps.length() < 2 || deps[0] != '"' || deps[deps.size() - 1] != '"') |
| + return kDepsCategoryOther; |
| + |
| + if (deps[1] == ':') |
| + return kDepsCategoryLocal; |
| + |
| + if (deps[1] == '/') |
| + return kDepsCategoryAbsolute; |
| + |
| + return kDepsCategoryRelative; |
| +} |
| + |
| std::tuple<base::StringPiece, base::StringPiece> SplitAtFirst( |
| base::StringPiece str, |
| char c) { |
| @@ -590,7 +610,8 @@ void ListNode::SortAsDepsList() { |
| SortList([](const ParseNode* a, const ParseNode* b) { |
| base::StringPiece astr = GetStringRepresentation(a); |
| base::StringPiece bstr = GetStringRepresentation(b); |
| - return SplitAtFirst(astr, ':') < SplitAtFirst(bstr, ':'); |
| + return std::make_pair(GetDepsCategory(astr), SplitAtFirst(astr, ':')) < |
| + std::make_pair(GetDepsCategory(bstr), SplitAtFirst(bstr, ':')); |
| }); |
| } |