mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 11:28:08 +00:00
optimin nits
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
|
||||
/// Display a progress bar in the terminal
|
||||
class ProgressBar {
|
||||
|
||||
private:
|
||||
const size_t BarWidth;
|
||||
const std::string Fill;
|
||||
@ -18,14 +19,17 @@ class ProgressBar {
|
||||
|
||||
public:
|
||||
ProgressBar() : ProgressBar(60, "#", " ") {
|
||||
|
||||
}
|
||||
|
||||
ProgressBar(size_t Width, const llvm::StringRef F, const llvm::StringRef R)
|
||||
: BarWidth(Width), Fill(F), Remainder(R) {
|
||||
|
||||
}
|
||||
|
||||
void update(float Progress, const llvm::StringRef Status = "",
|
||||
llvm::raw_ostream &OS = llvm::outs()) {
|
||||
|
||||
// No need to write once progress is 100%
|
||||
if (Progress > 100.0f) return;
|
||||
|
||||
@ -39,11 +43,17 @@ class ProgressBar {
|
||||
const auto Completed =
|
||||
static_cast<size_t>(Progress * static_cast<float>(BarWidth) / 100.0);
|
||||
for (size_t I = 0; I < BarWidth; ++I) {
|
||||
|
||||
if (I <= Completed) {
|
||||
|
||||
OS << Fill;
|
||||
|
||||
} else {
|
||||
|
||||
OS << Remainder;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// End bar
|
||||
@ -54,5 +64,8 @@ class ProgressBar {
|
||||
|
||||
// Write status text
|
||||
OS << " " << Status;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user