This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] libstdc++/38678


FWIW, calling sbumpc() for each character is inefficient,
especially when the size of the internal buffer is much
less than the size of the buffer being stored into, such
as in the unbuffered case. I suggest calling
streambuf::xsgetn() directly instead, like so:

+  template<typename _CharT, typename _Traits>
     basic_istream<_CharT, _Traits>&
     basic_istream<_CharT, _Traits>::
     read(char_type* __s, streamsize __n)
@@ -611,7 +627,7 @@
 	  ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
 	  try
 	    {
-	      _M_gcount = this->rdbuf()->sgetn(__s, __n);
+             typedef basic_streambuf<_CharT, _Traits> _Streambuf;
+	      _M_gcount = this->rdbuf()->_Streambuf::xsgetn(__s, __n);
 	      if (_M_gcount != __n)
 		__err |= (ios_base::eofbit | ios_base::failbit);
 	    }

(This requires that basic_streambuf be granted friendship
of basic_istream.)

Btw., I plan to bring this issue up on the library reflector
and propose that istream be allowed to call xsgetn() in addition
to uflow() and underflow() for efficiency.

Martin

Paolo Carlini wrote:
Hi,

tested x86_64-linux, committed to mainline.

Paolo.

PS: Happy New Year!

///////////////



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]