diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
| commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
| tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /include/streambuf | |
| parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
Notes
Diffstat (limited to 'include/streambuf')
| -rw-r--r-- | include/streambuf | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/streambuf b/include/streambuf index 6adfc9237c7d..603c68038796 100644 --- a/include/streambuf +++ b/include/streambuf @@ -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; } |
