This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Speed-up istreambuf_iterator


Hi,

the below is the version that I have finally committed (uses our
single-return coding convention and sometimes is slighlty better
performance-wise)

Regtested x86/ia64-linux.

Paolo.

/////////////
2004-11-08  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/streambuf_iterator.h (class istreambuf_iterator):
	Consistently use _M_c to cache the current char, i.e., not only
	when operator++(int) is involved; change _M_c to mutable.
	(_M_get()): Always save the return value of _M_sbuf->sgetc() into
	_M_c.
	* testsuite/22_locale/time_get/get_monthname/char/1.cc: Fix
	(long standing) typo.
	* testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc: Likewise.
	* testsuite/22_locale/time_get/get_weekday/char/1.cc: Likewise.
	* testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc: Likewise.
diff -urN libstdc++-v3-1/include/bits/streambuf_iterator.h libstdc++-v3/include/bits/streambuf_iterator.h
--- libstdc++-v3-1/include/bits/streambuf_iterator.h	2004-02-08 05:46:42.000000000 +0100
+++ libstdc++-v3/include/bits/streambuf_iterator.h	2004-11-08 11:56:25.000000000 +0100
@@ -72,7 +72,7 @@
       // NB: This implementation assumes the "end of stream" value
       // is EOF, or -1.
       mutable streambuf_type*	_M_sbuf;
-      int_type			_M_c;
+      mutable int_type		_M_c;
 
     public:
       ///  Construct end of input stream iterator.
@@ -157,10 +157,11 @@
 	int_type __ret = __eof;
 	if (_M_sbuf)
 	  {
-	    if (!traits_type::eq_int_type(_M_c, __eof))
+	    if (!traits_type::eq_int_type(_M_c, __eof)
+		|| !traits_type::eq_int_type((_M_c = _M_sbuf->sgetc()),
+					     __eof))
 	      __ret = _M_c;
-	    else if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()),
-					      __eof))
+	    else
 	      _M_sbuf = 0;
 	  }
 	return __ret;
diff -urN libstdc++-v3-1/testsuite/22_locale/time_get/get_monthname/char/1.cc libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc
--- libstdc++-v3-1/testsuite/22_locale/time_get/get_monthname/char/1.cc	2004-04-08 01:13:39.000000000 +0200
+++ libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc	2004-11-07 18:05:03.000000000 +0100
@@ -102,7 +102,7 @@
   tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
   VERIFY( time06.tm_mon == 4 );
   VERIFY( errorstate == ios_base::failbit );
-  VERIFY( *is_it05 == 'l');
+  VERIFY( *is_it06 == 'l');
 }
 
 int main()
diff -urN libstdc++-v3-1/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc
--- libstdc++-v3-1/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc	2004-04-08 01:13:41.000000000 +0200
+++ libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc	2004-11-07 18:05:20.000000000 +0100
@@ -102,7 +102,7 @@
   tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
   VERIFY( time06.tm_mon == 4 );
   VERIFY( errorstate == ios_base::failbit );
-  VERIFY( *is_it05 == L'l' );
+  VERIFY( *is_it06 == L'l' );
 }
 
 int main()
diff -urN libstdc++-v3-1/testsuite/22_locale/time_get/get_weekday/char/1.cc libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc
--- libstdc++-v3-1/testsuite/22_locale/time_get/get_weekday/char/1.cc	2004-04-08 01:13:48.000000000 +0200
+++ libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc	2004-11-07 18:06:06.000000000 +0100
@@ -106,7 +106,7 @@
   tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
   VERIFY( time06.tm_wday == 4 );
   VERIFY( errorstate == ios_base::failbit );
-  VERIFY( *is_it05 == 'u');
+  VERIFY( *is_it06 == 'u');
 }
 
 int main()
diff -urN libstdc++-v3-1/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc
--- libstdc++-v3-1/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc	2004-04-08 01:13:51.000000000 +0200
+++ libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc	2004-11-07 18:06:17.000000000 +0100
@@ -106,7 +106,7 @@
   tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
   VERIFY( time06.tm_wday == 4 );
   VERIFY( errorstate == ios_base::failbit );
-  VERIFY( *is_it05 == L'u' );
+  VERIFY( *is_it06 == L'u' );
 }
 
 int main()

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