summaryrefslogtreecommitdiff
path: root/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-03-01 11:47:00 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-03-01 11:47:00 +0000
commitee5e607355f76f0de64ea9ff5a380a5317627e05 (patch)
tree6282a5bbd14788534d8504dc154b12f953bc1589 /lib/Support/Statistic.cpp
parent73bbab9d755b7b196a0ba6a41caf9391a1d0abdf (diff)
downloadllvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.gz
llvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.bz2
llvm-ee5e607355f76f0de64ea9ff5a380a5317627e05.tar.xz
Now that we have C++11, turn simple functors into lambdas and remove a ton of boilerplate.
No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Statistic.cpp')
-rw-r--r--lib/Support/Statistic.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index 9c28176b73..56c3b0f565 100644
--- a/lib/Support/Statistic.cpp
+++ b/lib/Support/Statistic.cpp
@@ -84,20 +84,6 @@ void Statistic::RegisterStatistic() {
}
}
-namespace {
-
-struct NameCompare {
- bool operator()(const Statistic *LHS, const Statistic *RHS) const {
- int Cmp = std::strcmp(LHS->getName(), RHS->getName());
- if (Cmp != 0) return Cmp < 0;
-
- // Secondary key is the description.
- return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
- }
-};
-
-}
-
// Print information when destroyed, iff command line option is specified.
StatisticInfo::~StatisticInfo() {
llvm::PrintStatistics();
@@ -124,7 +110,14 @@ void llvm::PrintStatistics(raw_ostream &OS) {
}
// Sort the fields by name.
- std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(), NameCompare());
+ std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(),
+ [](const Statistic *LHS, const Statistic *RHS) {
+ if (int Cmp = std::strcmp(LHS->getName(), RHS->getName()))
+ return Cmp < 0;
+
+ // Secondary key is the description.
+ return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
+ });
// Print out the statistics header...
OS << "===" << std::string(73, '-') << "===\n"