#ifndef _LIBSTDCXX_FBSTRING
SCOPE_EXIT {
assert(this->size() == size);
- assert(memcmp(this->data(), data, size * sizeof(Char)) == 0);
+ assert(size == 0 || memcmp(this->data(), data, size * sizeof(Char)) == 0);
};
#endif
#endif
} else
#endif
{
- fbstring_detail::pod_copy(data, data + size, small_);
+ if (size != 0) {
+ fbstring_detail::pod_copy(data, data + size, small_);
+ }
}
setSmallSize(size);
} else {
}
basic_fbstring& append(size_type n, value_type c) {
- resize(size() + n, c);
+ Invariant checker(*this);
+ auto pData = store_.expand_noinit(n, /* expGrowth = */ true);
+ fbstring_detail::pod_fill(pData, pData + n, c);
return *this;
}
Invariant checker(*this);
// s can alias this, we need to use pod_move.
- if (size() >= n) {
+ if (n == 0) {
+ resize(0);
+ } else if (size() >= n) {
fbstring_detail::pod_move(s, s + n, store_.mutable_data());
resize(n);
assert(size() == n);
enforce(pos <= size(), std::__throw_out_of_range, "");
procrustes(n, size() - pos);
- fbstring_detail::pod_copy(
- data() + pos,
- data() + pos + n,
- s);
+ if (n != 0) {
+ fbstring_detail::pod_copy(data() + pos, data() + pos + n, s);
+ }
return n;
}