This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Rethinking... (Re: RFC: fp printing speedup...)


On Thu, Nov 13, 2003 at 10:45:09PM -0500, Jerry Quinn wrote:
>  > I'm asking because I think that eventually we'll have it, because
>  > 'narrow', 'widen', 'is' (we have already a PR for this: 11723) must
>  > be fast in order to have an efficient implementation of the
>  > monetary and time facets.
> 
> We can certainly speed this stuff up.  Do we actually need a ctype
> cache or just caches for money and time?  I don't think we can speed
> up user code that accesses ctype.widen, since the spec says this must
> call the virtual function.

> Well, wait.  What if ctype.widen looked like:
> 
> CharT widen(char) {
>   if (!cache) {
> 	cache = getcache();
> 	do_widen(cache.CharTarray, cache.chararry);
>   }
>   return cache.CharTarray[char];
> }
> 
> Would this help the speed?


I don't think a ctype cache would help much, if at all.
Better to avoid calling ctype<>::widen(char) too frequently.

> BTW, to me the standard looks very vague on the issue of whether array
> widen must return the same results as char widen.  The standard says
> that the array form transforms each character in the array.
> 
> Standards folk (Matt, Nathan, Martin) - do you know if the standard
> intends that the following return true:
> 
> bool test(char c)
> {
>   ctype<charT> ct = use_facet...;
>   char carray[1];
>   carray[0] = c;	
>   charT array[1];
>   charT r = ct.do_widen(c);
>   ct.do_widen(carray, carray+1, array);
>   return r == array[0];
> }
> 
> To me the standard seems to imply this, but no guarantees are given.
> If the standard doesn't intend this to be true, that makes the array
> form nearly useless, no?
> 
> If the standard does intend this to be the case, then we don't need to
> loop with widen(char) and can use the array form instead.

Absolutely you can use the array form.  Anybody who suggested that
anything should work right when widen gives different results for 
single char and array forms would be laughed off the list.

Nathan Myers
ncm-nospam@cantrip.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]