--- Begin Message ---
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: Jerry Quinn <jlquinn at optonline dot net>, libstdc++ at gcc dot gnu dot org
- Date: Thu, 13 Feb 2003 08:48:07 -0500
- Subject: Re: [Patch] Fix libstdc++/9563
- Original-recipient: rfc822;jlquinn@optonline.net
- References: <E18jADJ-0004cn-00@tiamat> <3E4B6287.1040601@unitus.it>
Paolo Carlini writes:
> 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?
Well, we're still a factor of 2 slower than gcc 2.95 for basic number
and small string writing. So every little bit helps.
> 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.
This looks great. I wish I'd thought of it :-)
Jerry
--- End Message ---