[PATCH] D21103: optimized xsgetn for better performance

Evandro Menezes via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 09:07:18 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL272401: [streambuf] Added call to traits_type::copy to common case in xsgetn() (authored by evandro).

Changed prior to commit:
  http://reviews.llvm.org/D21103?vs=60222&id=60362#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21103

Files:
  libcxx/trunk/include/streambuf

Index: libcxx/trunk/include/streambuf
===================================================================
--- libcxx/trunk/include/streambuf
+++ libcxx/trunk/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;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21103.60362.patch
Type: text/x-patch
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160610/7b2830ff/attachment-0001.bin>


More information about the llvm-commits mailing list