From 885748d4c2eb3912cc0c89e1176f396ca0f903cb Mon Sep 17 00:00:00 2001 From: Pranav Srinivas Kumar Date: Sun, 24 May 2020 22:47:18 -0500 Subject: [PATCH] Reverted minor changes to stream helper w.r.t checking if fill, lead and remainder are empty --- include/indicators/details/stream_helper.hpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/indicators/details/stream_helper.hpp b/include/indicators/details/stream_helper.hpp index 9e01e3f..2715c0b 100644 --- a/include/indicators/details/stream_helper.hpp +++ b/include/indicators/details/stream_helper.hpp @@ -136,21 +136,18 @@ public: std::ostream &write(float progress) { auto pos = static_cast(progress * bar_width / 100.0); - for (size_t i = 0; i < bar_width;) { - std::string next{""}; - size_t current_display_width = 0; + for (size_t i = 0, current_display_width = 0; i < bar_width;) { + std::string next; - if (i < pos && !fill.empty()) { + if (i < pos) { next = fill; current_display_width = unicode::display_width(fill); - } else if (i == pos && !lead.empty()) { + } else if (i == pos) { next = lead; current_display_width = unicode::display_width(lead); } else { - if (!remainder.empty()) { - next = remainder; - current_display_width = unicode::display_width(remainder); - } + next = remainder; + current_display_width = unicode::display_width(remainder); } i += current_display_width; @@ -218,4 +215,4 @@ private: }; } // namespace details -} // namespace indicators +} // namespace indicators \ No newline at end of file