to{upper,lower}_ascii in Samba 3
Jeremy Allison
jra at samba.org
Fri Jun 25 10:40:32 MDT 2010
On Fri, Jun 25, 2010 at 06:35:07PM +0200, Jelmer Vernooij wrote:
> Samba 3 has some nice utility functions for converting ascii characters
> to uppercase or lowercase. However, there appear to be two versions:
>
> to{upper,lower}_ascii and to{upper,lower}_ascii_fast
>
> The first pair of functions seems to do conversion to uppercase by
> converting to UCS2, changing case and then converting back. The second
> pair uses a lookup table.
>
> Is there a good reason for keeping both around rather than using the
> second pair everywhere?
toupper_ascii_fast is a macro that has the warning...
/* Warning - this must only be called with 0 <= c < 128. IT WILL
* GIVE GARBAGE if c > 128 or c < 0. JRA.
*/
Note there is no tolower_ascii_fast()
I don't think the other versions have this restriction, so
I think we need both. The XXX_fast() call is an optimization
in heavily used code, with tests above its use.
No objections to it being moved to common code though.
Jeremy.
More information about the samba-technical
mailing list