This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] libstdc++/38678
- From: Martin Sebor <sebor at roguewave dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 01 Jan 2009 11:29:33 -0700
- Subject: Re: [v3] libstdc++/38678
- References: <495C9673.6050106@oracle.com>
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!
///////////////