[PATCH] libstdc++/8761 and libstdc++/7076
Nathan Myers
ncm-nospam@cantrip.org
Sun Jan 12 06:42:00 GMT 2003
On Sat, Jan 11, 2003 at 12:36:12PM -0500, Jerry Quinn wrote:
> Do any of you think it's worth trying to do the same exercise with
> floating point output? It's going to be significantly more complex, I
> suspect, between all the different floating point formats that are
> supported.
You can gather all the information needed for floating-point
formatting in one place, regardless of which format you will
be using. E.g., you may cache the widenings of 'e' and 'E'
even if you won't be using them this time.
You might consider storing a pointer to the correct formatting
function at the time it is determined (when setting the flags).
This is not always a win -- calling through a function pointer
can be very slow on some heavily-pipelined machines, compared with
(e.g.) one or a few conditional branches that just skip over a few
instructions. (Don't take my word for it, though -- it probably
varies with each CPU major-version, so you have to measure and
see.) The alternative to try is an enum describing the format,
and a switch statement to dispatch the different modes.
For some reason CPU designers seem to devote enormous resources
to optimizing switch statements, at the expense of speed in calling
through function pointers. (Or maybe that was the fashion five
years ago.)
Nathan Myers
ncm-nospam@cantrip.org
More information about the Libstdc++
mailing list