This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix libstdc++/9563


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]