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] Simplify basic_streambuf::setg() and setp()?


Hi,

this don't like specially, but, if I'm right, may help
noticeably in inlining _M_create_pback, _M_destroy_pback and
_M_set_determinate (see:

http://gcc.gnu.org/ml/libstdc++/2003-05/msg00014.html)

The point is: I have checked the standard and a couple of
other implementations and cannot find support for the final
'if' of our current setg() and setp().

(bonus: a minor clean up of _M_destroy_pback)

Tested x86-linux. Ok?

Paolo.

///////////
2003-05-03  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_streambuf.h (setg, setp): Don't set _M_mode.

	* include/std/std_fstream.h (_M_destroy_pback): Don't set
	unnecessarily _M_pback_cur_save and _M_pback_end_save.
diff -urN libstdc++-v3-3/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-3/include/std/std_fstream.h	2003-04-29 01:51:36.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h	2003-05-04 01:02:36.000000000 +0200
@@ -201,8 +201,6 @@
 
 	    this->setg(this->_M_buf, _M_pback_cur_save + __off_cur, 
 		       _M_pback_end_save + __off_end);
-	    _M_pback_cur_save = NULL;
-	    _M_pback_end_save = NULL;
 	    _M_pback_init = false;
 	  }
       }
diff -urN libstdc++-v3-3/include/std/std_streambuf.h libstdc++-v3/include/std/std_streambuf.h
--- libstdc++-v3-3/include/std/std_streambuf.h	2003-04-29 01:51:36.000000000 +0200
+++ libstdc++-v3/include/std/std_streambuf.h	2003-05-04 01:03:15.000000000 +0200
@@ -508,8 +508,6 @@
 	_M_in_beg = __gbeg;
 	_M_in_cur = __gnext;
 	_M_in_end = __gend;
-	if (!(_M_mode & ios_base::in) && __gbeg && __gnext && __gend)
-	  _M_mode = _M_mode | ios_base::in;
       }
 
       // [27.5.2.3.2] put area access
@@ -555,8 +553,6 @@
       { 
 	_M_out_beg = _M_out_cur = _M_out_lim = __pbeg; 
 	_M_out_end = __pend;
-	if (!(_M_mode & ios_base::out) && __pbeg && __pend)
-	  _M_mode = _M_mode | ios_base::out;
       }
 
       // [27.5.2.4] virtual functions

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