This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: ctype optimization work
Paolo Carlini writes:
> Jerry Quinn wrote:
>
> >Any thoughts?
> >
> >
> Well, mine is *really* down-to-earth: as my preliminary tests show
>
> http://gcc.gnu.org/ml/libstdc++/2003-11/msg00351.html
>
> dealing with the wchar_t case first with a trivial table prepared at
> construction time, doesn't remove the virtual call overhead and doesn't
> provide all the advantages of a dynamic cache, but for sure promise to
> speed up noticeably many applications, in particular when the
> time_get/time_put facets are involved:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13341
>
> I mean to just implement this baseline thing, against which we can judge
> more sophisticated, but tricky alternatives.
I just looked closer at this. One problem is that you can't build the
table in the ctype<wchar_t> constructor. There's no way to delay the
table construction until a derived class constructor finishes
executing. If you construct the table too soon, that may break a
derived do_narrow function.
This means filling the cache on demand, within the do_narrow
function. However, it seems the cost of wctob is enough to justify
even this.
Also, in that code, you would have to also test for __wc >= 0, since
wchar_t is probably signed.
I thought it would be a cool trick to initialize the table in
use_facet, but that doesn't cover using the facet outside of the
locale :-(
Jerry