[Patch] Remove a dead seekoff from _M_underflow
Paolo Carlini
pcarlini@unitus.it
Thu May 22 17:02:00 GMT 2003
Hi,
consider this code from the current _M_underflow:
if (this->_M_in_cur < this->_M_in_end)
{
__ret = traits_type::to_int_type(*this->_M_in_cur);
if (__bump)
_M_move_in_cur(1);
return __ret;
}
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
if (this->_M_in_cur > this->_M_in_beg)
{
if (__testout)
_M_overflow();
else if (this->_M_in_cur != _M_filepos)
_M_file.seekoff(this->_M_in_cur - _M_filepos, ios_base::cur,
ios_base::in);
}
When !__testout for sure _M_out_cur_move is never called and this
implies that _M_in_end is stuck at the value set by the last
_M_set_buffer call. Since in the code above __testin is true,
_M_in_end == _M_filepos (see _M_set_buffer) and therefore, in the
second block above always _M_in_cur == _M_filepos.
I also take the occasion to rewrite the resulting simplified 'if'
in terms of _M_out_* pointers (equivalent but more clear, IMO) and
remove a redundant 'if' not shown above: everywhere else
_M_destroy_pback is called without checking for _M_pback_init, this
is only a remnant from a previous more convoluted 'if' block.
Tested x86-linux, also put an abort() in the original code in place
of the removed 'if' branch and ran the testsuite.
Paolo.
//////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_under
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030522/a3d02ff3/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_under
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030522/a3d02ff3/attachment-0001.ksh>
More information about the Libstdc++
mailing list