Skip to content

Commit 066bc49

Browse files
[modularize] Use std::tie to implement operator< (NFC) (#139410)
1 parent fadd427 commit 066bc49

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

clang-tools-extra/modularize/Modularize.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,8 @@ struct Location {
406406
}
407407

408408
friend bool operator<(const Location &X, const Location &Y) {
409-
if (X.File != Y.File)
410-
return X.File < Y.File;
411-
if (X.Line != Y.Line)
412-
return X.Line < Y.Line;
413-
return X.Column < Y.Column;
409+
return std::tie(X.File, X.Line, X.Column) <
410+
std::tie(Y.File, Y.Line, Y.Column);
414411
}
415412
friend bool operator>(const Location &X, const Location &Y) { return Y < X; }
416413
friend bool operator<=(const Location &X, const Location &Y) {

clang-tools-extra/modularize/PreprocessorTracker.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,8 @@ class PPItemKey {
494494
return Column == Other.Column;
495495
}
496496
bool operator<(const PPItemKey &Other) const {
497-
if (Name < Other.Name)
498-
return true;
499-
else if (Name > Other.Name)
500-
return false;
501-
if (File < Other.File)
502-
return true;
503-
else if (File > Other.File)
504-
return false;
505-
if (Line < Other.Line)
506-
return true;
507-
else if (Line > Other.Line)
508-
return false;
509-
return Column < Other.Column;
497+
return std::tie(Name, File, Line, Column) <
498+
std::tie(Other.Name, Other.File, Other.Line, Other.Column);
510499
}
511500
StringHandle Name;
512501
HeaderHandle File;

0 commit comments

Comments
 (0)