interesting fact about StrCaseCmp

Simo Sorce simo.sorce at xsec.it
Tue Feb 18 13:56:05 GMT 2003


Look at other parts in the code, a nice idea is to compare character by
character until the string is an ASCII one, as soon as we detect a non
ascii character we revert to the standard method and re-compare the
strings, Tridge has gained very good optimizations with this twchnique.

Simo.

On Tue, 2003-02-18 at 01:35, Martin Pool wrote:
> On 18 Feb 2003, Andrew Bartlett <abartlet at samba.org> wrote:
> 
> > Possibly only for long strings?  But then that is probably
> > micro-optimization.  
> 
> If we really cared about optimizing this function, then we would
> compare character-by-character rather than converting both strings to
> uppercase first.  This is a bit hard for some wierd encodings I know,
> but it ought to be possible to do it in charcnv.c.
> 
> The case where we compare, for example, a thousand-character string to
> the empty string is ridiculously slow at the moment.
> 
> I don't know if this is a problem for Samba overall or not, so I'm not
> touching it at the moment.
> 
> 	int StrCaseCmp(const char *s, const char *t)
> 	{
> 		pstring buf1, buf2;
> 		unix_strupper(s, strlen(s)+1, buf1, sizeof(buf1));
> 		unix_strupper(t, strlen(t)+1, buf2, sizeof(buf2));
> 		return strcmp(buf1,buf2);
> 	}
-- 
Simo Sorce - simo.sorce at xsec.it
Xsec s.r.l.
via Durando 10 Ed. G - 20158 - Milano
tel. +39 02 2399 7130 - fax: +39 02 700 442 399
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20030218/890a19e6/attachment.bin


More information about the samba-technical mailing list