[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

llvm-svn: 272401
This commit is contained in:
Evandro Menezes 2016-06-10 16:00:29 +00:00
parent a3a0a60cff
commit 72d6a934cc

View File

@ -495,12 +495,22 @@ basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
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;
}