[PATCH] libstdc++/8761 and libstdc++/7076
Jerry Quinn
jlquinn@optonline.net
Sat Jan 11 17:39:00 GMT 2003
Nathan Myers <ncm-nospam at cantrip dot org> wrote:
> On Fri, Jan 10, 2003 at 01:50:20AM -0500, Jerry Quinn wrote:
> > This patch provides specializations for integer formatting within libstdc++.
> > It nearly halves the time for the PR 8761 testcase from 21 seconds to 11
> > seconds. The PR 7076 testcase reduces from 7 seconds to 5.6 with this patch.
> This is most excellent.
>
> It seems to me we could get more improvement by eliminating the
> format strings entirely, and working directly off the iosbase
> members. We could do even better by caching decisions when
> format flags are set, rather than looking them all up each time
> operator<< is called. Minimally, this might mean calling a
> streamlined decimal-integer formatter when we know none of the
> complications (hex etc.) is selected.
The next patch I'm going to do will use the _M_literals cached string
to clobber the format string for integer output and also avoid a call
to ctype.widen(). This may shave off another 1 second or so.
> We should get a lot of improvement by eliminating memory allocations
> from the main code path, and instead using local buffers, or a
> persistent buffer in the iosbase object. (I seem to recall there
> were some malloc calls there, but haven't rechecked.)
Benjamin Kosnik <bkoz at redhat dot com> wrote:
> Yeah. I'm more in favor of a __locale_cache, then the formatting bits
> (which dupicates parts of __num_base.)
Saving the formatting bits amortizes the cost of a virtual function
call such as ctype.do_widen(). Every bit helps.
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.
Jerry Quinn
More information about the Libstdc++
mailing list