diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-10-16 16:30:34 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-10-16 16:30:34 +0000 |
commit | 962bad70f4277841cf6278306caa93ebce304b48 (patch) | |
tree | f8e798ee4db25f43337848f01fcc09b276b9d3e1 /lib/Support/Statistic.cpp | |
parent | 47b8798c0bf0944b24051bc21d85d93a2732676a (diff) |
Let printf do the formatting instead aligning strings ourselves.
While at it, merge some format strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Statistic.cpp')
-rw-r--r-- | lib/Support/Statistic.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index 1e733d92e6..04a44a0f71 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -24,6 +24,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Mutex.h" @@ -126,13 +127,11 @@ void llvm::PrintStatistics(raw_ostream &OS) { << "===" << std::string(73, '-') << "===\n\n"; // Print all of the statistics. - for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) { - std::string CountStr = utostr(Stats.Stats[i]->getValue()); - OS << std::string(MaxValLen-CountStr.size(), ' ') - << CountStr << " " << Stats.Stats[i]->getName() - << std::string(MaxNameLen-std::strlen(Stats.Stats[i]->getName()), ' ') - << " - " << Stats.Stats[i]->getDesc() << "\n"; - } + for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) + OS << format("%*u %-*s - %s\n", + MaxValLen, Stats.Stats[i]->getValue(), + MaxNameLen, Stats.Stats[i]->getName(), + Stats.Stats[i]->getDesc()); OS << '\n'; // Flush the output stream. OS.flush(); |