reserve capacity to fast_oss

This commit is contained in:
gabime
2014-03-16 20:48:37 +02:00
parent 08ba1791ba
commit 0209765b8f
2 changed files with 10 additions and 1 deletions

View File

@@ -40,6 +40,12 @@ protected:
virtual std::streamsize xsputn(const char_type* s, std::streamsize count) override
{
auto ssize = _str.size();
auto cap_left = _str.capacity() - ssize;
if(cap_left < static_cast<std::size_t>(count))
_str.reserve(ssize + count + 128);
_str.append(s, static_cast<unsigned int>(count));
return count;
}