We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa8a308 commit 4cce5f4Copy full SHA for 4cce5f4
1 file changed
include/fmt/base.h
@@ -1844,10 +1844,13 @@ template <typename T> class buffer {
1844
void
1845
append(const U* begin, const U* end) {
1846
while (begin != end) {
1847
- auto count = to_unsigned(end - begin);
1848
- try_reserve(size_ + count);
1849
auto free_cap = capacity_ - size_;
1850
- if (free_cap < count) count = free_cap;
+ auto count = to_unsigned(end - begin);
+ if (free_cap < count) {
+ grow_(*this, size_ + count);
1851
+ free_cap = capacity_ - size_;
1852
+ count = (count < free_cap) ? count : free_cap;
1853
+ }
1854
// A loop is faster than memcpy on small sizes.
1855
T* out = ptr_ + size_;
1856
for (size_t i = 0; i < count; ++i) out[i] = begin[i];
0 commit comments