[v3] speed tweak to __int_to_char
Jerry Quinn
jlquinn@optonline.net
Fri Jul 4 23:09:00 GMT 2003
[message only made it to gcc-patches before]
Relocating the common case of decimal printing first improves the
overall speed on testsuite/performance/ofstream_insert_float.cc by
about 0.1 sec to ~3.8 seconds.
OK for 3.3 and mainline?
Jerry
2003-07-04 Jerry Quinn <jlquinn@optonline.net>
* include/bits/locale_facets.tcc (__int_to_char): Move common
case to the top.
*** locale_facets.tcc.~1.103.~ Tue Jul 1 01:28:56 2003
--- locale_facets.tcc Thu Jul 3 22:22:20 2003
***************
*** 692,698 ****
_CharT* __buf = __out + __size - 1;
_CharT* __bufend = __out + __size;
! if (__builtin_expect(__basefield == ios_base::oct, false))
{
// Octal.
do
--- 714,735 ----
_CharT* __buf = __out + __size - 1;
_CharT* __bufend = __out + __size;
! if (__builtin_expect(__basefield != ios_base::oct &&
! __basefield != ios_base::hex, true))
! {
! // Decimal.
! do
! {
! *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
! __v /= 10;
! }
! while (__v != 0);
! if (__neg)
! *__buf-- = __lit[__num_base::_S_ominus];
! else if (__flags & ios_base::showpos)
! *__buf-- = __lit[__num_base::_S_oplus];
! }
! else if (__basefield == ios_base::oct)
{
// Octal.
do
***************
*** 704,710 ****
if (__showbase)
*__buf-- = __lit[__num_base::_S_odigits];
}
! else if (__builtin_expect(__basefield == ios_base::hex, false))
{
// Hex.
const bool __uppercase = __flags & ios_base::uppercase;
--- 741,747 ----
if (__showbase)
*__buf-- = __lit[__num_base::_S_odigits];
}
! else
{
// Hex.
const bool __uppercase = __flags & ios_base::uppercase;
***************
*** 724,743 ****
*__buf-- = __lit[__num_base::_S_odigits];
}
}
- else
- {
- // Decimal.
- do
- {
- *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
- __v /= 10;
- }
- while (__v != 0);
- if (__neg)
- *__buf-- = __lit[__num_base::_S_ominus];
- else if (__flags & ios_base::showpos)
- *__buf-- = __lit[__num_base::_S_oplus];
- }
int __ret = __bufend - __buf - 1;
return __ret;
}
--- 761,766 ----
More information about the Libstdc++
mailing list