Skip to content

Commit

Permalink
optimize append (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
moiwi authored Mar 13, 2021
1 parent c8d8b88 commit b8ff3c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,15 @@ using is_fast_float = bool_constant<std::numeric_limits<T>::is_iec559 &&
template <typename T>
template <typename U>
void buffer<T>::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_;
if (free_cap < count) count = free_cap;
std::uninitialized_copy_n(begin, count, make_checked(ptr_ + size_, count));
size_ += count;
begin += count;
} while (begin != end);
}
}

template <typename OutputIt, typename T, typename Traits>
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit b8ff3c1

Please sign in to comment.