[libcxx] r176573 - Have basic_istream::read call sgetn intead of sbumpc individual characters. This addresses http://llvm.org/bugs/show_bug.cgi?id=15427.

Howard Hinnant hhinnant at apple.com
Wed Mar 6 11:27:56 PST 2013


Author: hhinnant
Date: Wed Mar  6 13:27:56 2013
New Revision: 176573

URL: http://llvm.org/viewvc/llvm-project?rev=176573&view=rev
Log:
Have basic_istream::read call sgetn intead of sbumpc individual characters.  This addresses http://llvm.org/bugs/show_bug.cgi?id=15427.

Modified:
    libcxx/trunk/include/istream

Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=176573&r1=176572&r2=176573&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Wed Mar  6 13:27:56 2013
@@ -1216,16 +1216,9 @@ basic_istream<_CharT, _Traits>::read(cha
         sentry __sen(*this, true);
         if (__sen)
         {
-            for (; __gc_ < __n; ++__gc_)
-            {
-                typename traits_type::int_type __i = this->rdbuf()->sbumpc();
-                if (traits_type::eq_int_type(__i, traits_type::eof()))
-                {
-                   this->setstate(ios_base::failbit | ios_base::eofbit);
-                   break;
-                }
-                *__s++ = traits_type::to_char_type(__i);
-            }
+            __gc_ = this->rdbuf()->sgetn(__s, __n);
+            if (__gc_ != __n)
+                this->setstate(ios_base::failbit | ios_base::eofbit);
         }
         else
             this->setstate(ios_base::failbit);





More information about the cfe-commits mailing list