[streambuf] Added call to traits_type::copy to common case in xsgetn()
Patch by Laman Sole <laxman.g@partner.samsung.com>, Sebastian Pop
<s.pop@samsung.com>, Aditya Kumar <aditya.k7@samsung.com>
Differential Revision: http://reviews.llvm.org/D21103
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272401 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/streambuf b/include/streambuf
index 603c680..7544aaf 100644
--- a/include/streambuf
+++ b/include/streambuf
@@ -495,12 +495,22 @@
const int_type __eof = traits_type::eof();
int_type __c;
streamsize __i = 0;
- for (;__i < __n; ++__i, ++__s)
+ while(__i < __n)
{
if (__ninp_ < __einp_)
- *__s = *__ninp_++;
+ {
+ const streamsize __len = _VSTD::min(__einp_ - __ninp_, __n - __i);
+ traits_type::copy(__s, __ninp_, __len);
+ __s += __len;
+ __i += __len;
+ this->gbump(__len);
+ }
else if ((__c = uflow()) != __eof)
+ {
*__s = traits_type::to_char_type(__c);
+ ++__s;
+ ++__i;
+ }
else
break;
}