[libcxx] r272401 - [streambuf] Added call to traits_type::copy to common case in xsgetn()

Evandro Menezes via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 09:00:29 PDT 2016


Author: evandro
Date: Fri Jun 10 11:00:29 2016
New Revision: 272401

URL: http://llvm.org/viewvc/llvm-project?rev=272401&view=rev
Log:
[streambuf] Added call to traits_type::copy to common case in xsgetn()

Patch by Laman Sole <laxman.g at partner.samsung.com>, Sebastian Pop
<s.pop at samsung.com>, Aditya Kumar <aditya.k7 at samsung.com>

Differential Revision: http://reviews.llvm.org/D21103

Modified:
    libcxx/trunk/include/streambuf

Modified: libcxx/trunk/include/streambuf
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/streambuf?rev=272401&r1=272400&r2=272401&view=diff
==============================================================================
--- libcxx/trunk/include/streambuf (original)
+++ libcxx/trunk/include/streambuf Fri Jun 10 11:00:29 2016
@@ -495,12 +495,22 @@ basic_streambuf<_CharT, _Traits>::xsgetn
     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;
     }




More information about the cfe-commits mailing list