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]

[v3] More libstdc++/8761 and 7076


Continuing to prod at the I/O regression from 2.95 ...

When inserting chars and strings, we were calling basic_ostream::write(),
which creates redundant sentry objects.

No regressions.

OK for 3.3 and mainline?  I actually think it's safe for 3.2 as well, but
won't have a huge impact.

2003-02-03  Jerry Quinn  <jlquinn@optonline.net>

        * ostream.tcc (_M_write): New.
	(basic_ostream::write): Use it.
	(operator<<(basic_ostream, _CharT)): Ditto.
	(operator<<(basic_ostream, char)): Ditto.
	(operator<<(basic_ostream, _CharT*)): Ditto.
	(operator<<(basic_ostream, char*)): Ditto.
	(operator<<(basic_ostream, basic_string)): Ditto.



*** ostream.tcc.~1.31.~	Tue Jul 30 22:47:33 2002
--- ostream.tcc	Mon Feb  3 00:51:58 2003
***************
*** 381,386 ****
--- 381,397 ----
        return *this;
      }
  
+   // Non-guarded core functionality of write().  Should get inlined out of existence.
+   template<typename _CharT, typename _Traits>
+     inline
+     void
+     _M_write(basic_ostream<_CharT, _Traits>& os, const _CharT* __s, streamsize __n)
+     {
+       streamsize __put = os.rdbuf()->sputn(__s, __n);
+       if ( __put != __n)
+ 	os.setstate(ios_base::badbit);
+     }
+ 
    template<typename _CharT, typename _Traits>
      basic_ostream<_CharT, _Traits>&
      basic_ostream<_CharT, _Traits>::write(const _CharT* __s, streamsize __n)
***************
*** 388,396 ****
        sentry __cerb(*this);
        if (__cerb)
  	{
! 	  streamsize __put = this->rdbuf()->sputn(__s, __n);
! 	  if ( __put != __n)
! 	    this->setstate(ios_base::badbit);
  	}
        return *this;
      }
--- 399,405 ----
        sentry __cerb(*this);
        if (__cerb)
  	{
! 	  _M_write(*this, __s, __n);
  	}
        return *this;
      }
***************
*** 478,484 ****
  						 &__c, __w, __len, false);
  		  __len = __w;
  		}
! 	      __out.write(__pads, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
--- 487,493 ----
  						 &__c, __w, __len, false);
  		  __len = __w;
  		}
! 	      _M_write(__out, __pads, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
***************
*** 514,520 ****
  					       &__c, __w, __len, false);
  		  __len = __w;
  		}
! 	      __out.write(__pads, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
--- 523,529 ----
  					       &__c, __w, __len, false);
  		  __len = __w;
  		}
! 	      _M_write(__out, __pads, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
***************
*** 549,555 ****
  		  __s = __pads;
  		  __len = __w;
  		}
! 	      __out.write(__s, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
--- 558,564 ----
  		  __s = __pads;
  		  __len = __w;
  		}
! 	      _M_write(__out, __s, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
***************
*** 598,604 ****
  		  __str = __pads;
  		  __len = __w;
  		}
! 	      __out.write(__str, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
--- 607,613 ----
  		  __str = __pads;
  		  __len = __w;
  		}
! 	      _M_write(__out, __str, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
***************
*** 637,643 ****
  		  __s = __pads;
  		  __len = __w;
  		}
! 	      __out.write(__s, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
--- 646,652 ----
  		  __s = __pads;
  		  __len = __w;
  		}
! 	      _M_write(__out, __s, __len);
  	      __out.width(0);
  	    }
  	  catch(exception& __fail)
***************
*** 678,687 ****
  	      __s = __pads;
  	      __len = __w;
  	    }
! 	  streamsize __res = __out.rdbuf()->sputn(__s, __len);
  	  __out.width(0);
- 	  if (__res != __len)
- 	    __out.setstate(ios_base::failbit);
  	}
        return __out;
      }
--- 687,694 ----
  	      __s = __pads;
  	      __len = __w;
  	    }
! 	  _M_write(__out, __s, __len);
  	  __out.width(0);
  	}
        return __out;
      }


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