[Patch] Fix libstdc++/9563
Paolo Carlini
pcarlini@unitus.it
Thu Feb 13 09:15:00 GMT 2003
Jerry Quinn wrote:
>Seems like this should reduce the impact of the extra required checking.
>
I agree. However, I have double checked a few other widespread
implementations: no-one seems to implement the optimization and
its additional complexity. Is it really worty?
But... I have got an idea... Do you believe would be ok rewriting
the code simply like this:
: _M_os(__os)
{
// XXX MT
if (__os.tie() && __os.good())
^^^^^^^^^^^^^^^^^^^^^^^^^
__os.tie()->flush();
if (__os.good())
_M_ok = true;
else
{
_M_ok = false;
__os.setstate(ios_base::failbit);
}
}
First blush, there is nothing wrong with checking that __os.tie() is not
a null pointer even if we are still not sure that __os.good() is true!
And in this way if __os.tie() is a null pointer we call __os.good() just
one time as in your solution.
What do you think?
Paolo.
More information about the Libstdc++
mailing list