From b8ff3c182004571dd9e1452239f1da6fde8f23e0 Mon Sep 17 00:00:00 2001 From: moiwi <71585945+moiwi@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:21:23 +0100 Subject: [PATCH] optimize append (#2164) --- include/fmt/format.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 5c689ac2..06f85a7c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -684,7 +684,7 @@ using is_fast_float = bool_constant::is_iec559 && template template void buffer::append(const U* begin, const U* end) { - do { + while (begin != end) { auto count = to_unsigned(end - begin); try_reserve(size_ + count); auto free_cap = capacity_ - size_; @@ -692,7 +692,7 @@ void buffer::append(const U* begin, const U* end) { std::uninitialized_copy_n(begin, count, make_checked(ptr_ + size_, count)); size_ += count; begin += count; - } while (begin != end); + } } template @@ -1576,7 +1576,7 @@ FMT_CONSTEXPR OutputIt write_padded(OutputIt out, auto it = reserve(out, size + padding * specs.fill.size()); if (left_padding != 0) it = fill(it, left_padding, specs.fill); it = f(it); - if (right_padding != 0) it = fill(it, padding - left_padding, specs.fill); + if (right_padding != 0) it = fill(it, right_padding, specs.fill); return base_iterator(out, it); }