[llvm] [BOLT][NFC] Eliminate uses of throwing std::map::at (PR #92950)
shaw young via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 16:02:12 PDT 2024
================
@@ -1553,36 +1553,28 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
const bool Ascending =
opts::DynoStatsSortOrderOpt == opts::DynoStatsSortOrder::Ascending;
- if (SortAll) {
- llvm::stable_sort(Functions,
- [Ascending, &Stats](const BinaryFunction *A,
- const BinaryFunction *B) {
- auto StatsItr = Stats.find(A);
- assert(StatsItr != Stats.end());
- const DynoStats &StatsA = StatsItr->second;
-
- StatsItr = Stats.find(B);
- assert(StatsItr != Stats.end());
- const DynoStats &StatsB = StatsItr->second;
-
- return Ascending ? StatsA < StatsB : StatsB < StatsA;
- });
- } else {
- llvm::stable_sort(
- Functions, [Ascending, &Stats](const BinaryFunction *A,
- const BinaryFunction *B) {
- auto StatsItr = Stats.find(A);
- assert(StatsItr != Stats.end());
- const DynoStats &StatsA = StatsItr->second;
-
- StatsItr = Stats.find(B);
- assert(StatsItr != Stats.end());
- const DynoStats &StatsB = StatsItr->second;
-
- return Ascending ? StatsA.lessThan(StatsB, opts::PrintSortedBy)
- : StatsB.lessThan(StatsA, opts::PrintSortedBy);
- });
- }
+ std::function<bool(const DynoStats &, const DynoStats &)>
+ DynoStatsComparator =
+ SortAll ? [](const DynoStats &StatsA,
----------------
shawbyoung wrote:
By sink - do you mean remove some tabs?
https://github.com/llvm/llvm-project/pull/92950
More information about the llvm-commits
mailing list