This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch/RFC] Speed-up istreambuf_iterator and... sorry Jon!
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- Date: Sun, 07 Nov 2004 22:09:32 +0100
- Subject: Re: [Patch/RFC] Speed-up istreambuf_iterator and... sorry Jon!
- References: <418E6C00.5060208@suse.de>
... actually, the patch can be simpler, and the result even more
efficient: operator++() and operator++(int) were already resetting
_M_c to eof when really necessary! :)
current
=======
6.130u 0.000s 0:06.16 99.5% 0+0k 0+0io 205pf+0w
iter patched (new)
==================
4.390u 0.000s 0:04.41 99.5% 0+0k 0+0io 202pf+0w
(regtested x86-linux)
Paolo.
///////////////
2004-11-xx 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 -prN libstdc++-v3-1/include/bits/streambuf_iterator.h libstdc++-v3/include/bits/streambuf_iterator.h
*** libstdc++-v3-1/include/bits/streambuf_iterator.h Sun Feb 8 05:46:42 2004
--- libstdc++-v3/include/bits/streambuf_iterator.h Sun Nov 7 21:46:43 2004
*************** namespace std
*** 72,78 ****
// NB: This implementation assumes the "end of stream" value
// is EOF, or -1.
mutable streambuf_type* _M_sbuf;
! int_type _M_c;
public:
/// Construct end of input stream iterator.
--- 72,78 ----
// NB: This implementation assumes the "end of stream" value
// is EOF, or -1.
mutable streambuf_type* _M_sbuf;
! mutable int_type _M_c;
public:
/// Construct end of input stream iterator.
*************** namespace std
*** 154,169 ****
_M_get() const
{
const int_type __eof = traits_type::eof();
- int_type __ret = __eof;
if (_M_sbuf)
{
! if (!traits_type::eq_int_type(_M_c, __eof))
! __ret = _M_c;
! else if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()),
! __eof))
! _M_sbuf = 0;
}
! return __ret;
}
bool
--- 154,168 ----
_M_get() const
{
const int_type __eof = traits_type::eof();
if (_M_sbuf)
{
! if (!traits_type::eq_int_type(_M_c, __eof)
! || !traits_type::eq_int_type((_M_c = _M_sbuf->sgetc()),
! __eof))
! return _M_c;
! _M_sbuf = 0;
}
! return __eof;
}
bool
diff -prN 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 Thu Apr 8 01:13:39 2004
--- libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/1.cc Sun Nov 7 18:05:03 2004
*************** void test01()
*** 102,108 ****
tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_mon == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it05 == 'l');
}
int main()
--- 102,108 ----
tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_mon == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it06 == 'l');
}
int main()
diff -prN 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 Thu Apr 8 01:13:41 2004
--- libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/1.cc Sun Nov 7 18:05:20 2004
*************** void test01()
*** 102,108 ****
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' );
}
int main()
--- 102,108 ----
tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_mon == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it06 == L'l' );
}
int main()
diff -prN 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 Thu Apr 8 01:13:48 2004
--- libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/1.cc Sun Nov 7 18:06:06 2004
*************** void test01()
*** 106,112 ****
tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_wday == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it05 == 'u');
}
int main()
--- 106,112 ----
tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_wday == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it06 == 'u');
}
int main()
diff -prN 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 Thu Apr 8 01:13:51 2004
--- libstdc++-v3/testsuite/22_locale/time_get/get_weekday/wchar_t/1.cc Sun Nov 7 18:06:17 2004
*************** void test01()
*** 106,112 ****
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' );
}
int main()
--- 106,112 ----
tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_wday == 4 );
VERIFY( errorstate == ios_base::failbit );
! VERIFY( *is_it06 == L'u' );
}
int main()