[v3] libstdc++/38678

Martin Sebor sebor@roguewave.com
Thu Jan 1 18:30:00 GMT 2009


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!
> 
> ///////////////
> 



More information about the Libstdc++ mailing list