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]

[Patch] Shorten a bit basic_filebuf::pbackfail


"... cut and _cut_ and *cut*"

Nathan Myers, March 2003

Seriously, -12 lines and no less clarity, IMHO.

Tested x86-linux.

Ok with you, Benjamin?

Paolo.

/////////
2003-04-25  Paolo Carlini  <pcarlini at unitus dot it>

	* include/bits/fstream.tcc (pbackfail): Shorten a bit (12 lines)
	the innermost 'if' by factoring out some code.
diff -prN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
*** libstdc++-v3-orig/include/bits/fstream.tcc	Tue Apr 22 19:32:25 2003
--- libstdc++-v3/include/bits/fstream.tcc	Fri Apr 25 21:24:12 2003
*************** namespace std
*** 196,222 ****
  	      const bool __testout = this->_M_mode & ios_base::out;
  	      const bool __testeq = traits_type::eq(__c, this->_M_in_cur[-1]);
  
  	      // Try to put back __c into input sequence in one of three ways.
  	      // Order these tests done in is unspecified by the standard.
  	      if (!__testeof && __testeq)
! 		{
! 		  --this->_M_in_cur;
! 		  if (__testout)
! 		    --this->_M_out_cur;
! 		  __ret = __i;
! 		}
  	      else if (__testeof)
  		{
- 		  --this->_M_in_cur;
- 		  if (__testout)
- 		    --this->_M_out_cur;
- 		  __ret = traits_type::not_eof(__i);
- 		}
- 	      else if (!__testeof)
- 		{
- 		  --this->_M_in_cur;
- 		  if (__testout)
- 		    --this->_M_out_cur;
  		  _M_pback_create();
  		  *this->_M_in_cur = __c; 
  		  __ret = __i;
--- 196,212 ----
  	      const bool __testout = this->_M_mode & ios_base::out;
  	      const bool __testeq = traits_type::eq(__c, this->_M_in_cur[-1]);
  
+ 	      --this->_M_in_cur;
+ 	      if (__testout)
+ 		--this->_M_out_cur;
  	      // Try to put back __c into input sequence in one of three ways.
  	      // Order these tests done in is unspecified by the standard.
  	      if (!__testeof && __testeq)
! 		__ret = __i;
  	      else if (__testeof)
+ 		__ret = traits_type::not_eof(__i);
+ 	      else
  		{
  		  _M_pback_create();
  		  *this->_M_in_cur = __c; 
  		  __ret = __i;


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