interesting fact about StrCaseCmp

Martin Pool mbp at samba.org
Tue Feb 18 07:23:41 GMT 2003


On 18 Feb 2003, jra at dp.samba.org wrote:
> You're not talking about allocating them for every call are you ?
> We call these functions a lot.....

One little malloc() could hardly make it any worse, although I will do
a test tomorrow to check.

Consider that at the moment StrCaseCmp converts both strings to
uppercase, even thought it will often be enough to examine just the
first few characters to find that there is a difference.  Not only
that, but case folding is done by converting the whole string to UCS2
and back, which is a particularly slow way to do it.

I wouldn't be surprised if by avoiding unncessary conversions we could
improve the average speed of StrCaseCmp at least tenfold, even if we
had to do malloc.

And anyhow as I said only the first 512 characters or less of the
strings are compared.  So really we're not even correct at the moment,
to say nothing of fast.

-- 
Martin 


More information about the samba-technical mailing list