to{upper,lower}_ascii in Samba 3

Jelmer Vernooij jelmer at samba.org
Fri Jun 25 11:04:35 MDT 2010


On Fri, 2010-06-25 at 09:40 -0700, Jeremy Allison wrote:
> 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.
Ah, thanks - that makes sense. I should have looked closer.

> No objections to it being moved to common code though.
Great, I'll look into that.

Cheers,

Jelmer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100625/44d1d315/attachment.pgp>


More information about the samba-technical mailing list