[v3] Speed up <char> do_narrow/widen

Paolo Carlini pcarlini@unitus.it
Sat Dec 13 11:48:00 GMT 2003


Jerry Quinn wrote:

>Along the lines of the recent patch to improve performance for
>ctype<wchar_t>::do_narrow/widen, this patch improves performance for
>ctype<char>.
>  
>
Very good work. Thanks! Do you have some numbers at hand?
A few trivial comments, for now...

>+      void _M_widen_init() const
>+      {
>+	char __tmp[sizeof(_M_widen)];
>+	for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
>+	  __tmp[__i] = __i;
>  
>
What about using size_t to go with sizeof()?

>+	+	char __tmp[sizeof(_M_narrow)];
>+	for (unsigned i = 0; i < sizeof(_M_narrow); ++i)
>+	  __tmp[i] = i;
>  
>
__i

>+  char bufin[] = "This was an attempt to bypass string construction just for test.";
>+  char bufout[sizeof(bufin) + 1];
>  
>
sizeof(bufin) it's ok...

Paolo.



More information about the Libstdc++ mailing list