This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [FYI] Forward movement on 9404
On Fri, Feb 21, 2003 at 06:07:26PM -0600, Benjamin Kosnik wrote:
> A minor nit:
>
> + if (_M_out_buf_size())
> __ret = this->sputc(traits_type::to_char_type(__c));
> else if (__len <= _M_string.max_size())
> {
> // Force-allocate, re-sync.
> _M_string = this->str();
> _M_string.reserve(__len);
> - this->_M_buf_size = __len;
> + this->_M_buf_size = _M_string.capacity();
> _M_really_sync(this->_M_in_cur - this->_M_in_beg,
> this->_M_out_cur - this->_M_out_beg);
> __ret = this->sputc(traits_type::to_char_type(__c));
>
> is there a way to coalesce these
>
> __ret = this->sputc(traits_type::to_char_type(__c));
>
> lines?
Yes. First, clean up the __testout tests:
if (__builtin_expect(!__testout, false))
return traits_type::eof();
if (__builtin_expect(__testeof, false))
return traits_type::not_eof();
__size_type __len = std::max(this->_M_buf_size, this->_M_buf_size_opt);
__len *= 2;
if (__builtin_expect(!__testwrite && __len > _M_string.max_size(), false))
return traits_type::eof();
if (!__testwrite)
{
// Force-allocate, re-sync
...
}
return this->sputc(traits_type::to_char_type(__c));
But can we let the basic_string<> figure out a new length for itself,
and allocate and copy, by calling capacity(__len)?
Nathan Myers
ncm-nospam at cantrip dot org