summaryrefslogtreecommitdiffstats
path: root/libcxx/include/streambuf
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-02-19 16:17:46 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-02-19 16:17:46 +0000
commit09921a571fa69ae273a8452da97d3ade0837ef15 (patch)
tree0ab4e82103215f4986579e4da24844128a2d37e7 /libcxx/include/streambuf
parentfca735cd58f321b7102810cba07e662702fbafdf (diff)
downloadbcm5719-llvm-09921a571fa69ae273a8452da97d3ade0837ef15.tar.gz
bcm5719-llvm-09921a571fa69ae273a8452da97d3ade0837ef15.zip
Make basic_streambuf::xsputn write characters in chunks whenever possible, instead of one at a time. References PR#10193
llvm-svn: 229866
Diffstat (limited to 'libcxx/include/streambuf')
-rw-r--r--libcxx/include/streambuf21
1 files changed, 16 insertions, 5 deletions
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index 6adfc9237c7..603c6803879 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/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;
}
OpenPOWER on IntegriCloud