Skip to content

Commit 56da4a9

Browse files
[llvm] Use std::tie to implement comparison functors (NFC) (#146197)
std::tie clearly expresses the intent while slightly shortening the code.
1 parent f90af1c commit 56da4a9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ struct LineLocation {
289289
LLVM_ABI void serialize(raw_ostream &OS);
290290

291291
bool operator<(const LineLocation &O) const {
292-
return LineOffset < O.LineOffset ||
293-
(LineOffset == O.LineOffset && Discriminator < O.Discriminator);
292+
return std::tie(LineOffset, Discriminator) <
293+
std::tie(O.LineOffset, O.Discriminator);
294294
}
295295

296296
bool operator==(const LineLocation &O) const {

llvm/lib/Target/Hexagon/HexagonBlockRanges.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct HexagonBlockRanges {
3737
unsigned Sub;
3838

3939
bool operator<(RegisterRef R) const {
40-
return Reg < R.Reg || (Reg == R.Reg && Sub < R.Sub);
40+
return std::tie(Reg, Sub) < std::tie(R.Reg, R.Sub);
4141
}
4242
};
4343
using RegisterSet = std::set<RegisterRef>;

llvm/lib/Target/X86/X86PreTileConfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ struct MIRef {
8080
bool operator<(const MIRef &RHS) const {
8181
// Comparison between different BBs happens when inserting a MIRef into set.
8282
// So we compare MBB first to make the insertion happy.
83-
return MBB < RHS.MBB || (MBB == RHS.MBB && Pos < RHS.Pos);
83+
return std::tie(MBB, Pos) < std::tie(RHS.MBB, RHS.Pos);
8484
}
8585
bool operator>(const MIRef &RHS) const {
8686
// Comparison between different BBs happens when inserting a MIRef into set.
8787
// So we compare MBB first to make the insertion happy.
88-
return MBB > RHS.MBB || (MBB == RHS.MBB && Pos > RHS.Pos);
88+
return std::tie(MBB, Pos) > std::tie(RHS.MBB, RHS.Pos);
8989
}
9090
};
9191

0 commit comments

Comments
 (0)