Make basic_streambuf::xsputn write characters in chunks whenever possible, instead of one at a time. References PR#10193
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@229866 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
784fa1eeba
commit
6b5a5e52f0
@ -536,12 +536,23 @@ basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n)
|
||||
{
|
||||
streamsize __i = 0;
|
||||
int_type __eof = traits_type::eof();
|
||||
for (; __i < __n; ++__s, ++__i)
|
||||
while( __i < __n)
|
||||
{
|
||||
if (__nout_ < __eout_)
|
||||
*__nout_++ = *__s;
|
||||
else if (overflow(traits_type::to_int_type(*__s)) == __eof)
|
||||
break;
|
||||
if (__nout_ >= __eout_)
|
||||
{
|
||||
if (overflow(traits_type::to_int_type(*__s)) == __eof)
|
||||
break;
|
||||
++__s;
|
||||
++__i;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i);
|
||||
traits_type::copy(__nout_, __s, __chunk_size);
|
||||
__nout_ += __chunk_size;
|
||||
__s += __chunk_size;
|
||||
__i += __chunk_size;
|
||||
}
|
||||
}
|
||||
return __i;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user