I'm the one who posted the original problem.  I used the profiler in the
emulator and found:

StrNCaselessCompare (this is the only one I tested but it might apply to the
others too) is SUBSTANTIALLY SLOWER IN 4.0 if you are comparing strings in
large data buffers.  I'm talking about 50 times slower or more!!!

The problem is only noticeable if you are working in large buffers which is
likely if you are working with large database records as I am doing.  Note
its not the size of the string you're comparing but the size of the buffer
the string is in.  I am checking short strings (<10 chars) but they are in
database records that could be 20k-30k or more (they are HTML pages).

The culprit is StrLen which is called twice for each call to
StrNCaselessCompare.  StrLen has always been very slow if the string was
very large.  For some reason StrLen is called twice to get the length of the
entire buffer.

I switched to TxtCaselessCompare and it ran much faster which seems to
contradict the other advice here that indicated the only difference would be
the time for StrNCaselessCompare to call TxtCaselessCompare.  That doesn't
seem to be the case since my application was totally unuseable in 4.0 until
I switched the calls.  Now it runs as it did in 3.x

Kevin

"Ken Krugler" <[EMAIL PROTECTED]> wrote in message
news:52356@palm-dev-forum...
>
> >  > From: Kevin
> >  >
> >  > I have a commerical application that has run fine under
> >  > all 3.x version of PalmOS. Under 4.0 it runs very slowly.
> >  > I have not been able to pinpoint any particular API calls
> >  > that run slower.  It appears as if the C code just runs
> >  > slower especially string manipulation and searching.
> >  > Anyone had a similar experience?
> >  >
> >
> >I think you'll find that StrCompare() and StrNCompare() are slower in the
> >4.0 SDK.
>
> StrCompare should be roughly comparable in speed, less the trap
> dispatch overhead of calling through to TxtCompare.
>
> StrNCompare will be slower in 4.0 - the longer the strings you're
> passing in, the bigger the performance issue.
>
> >If you are certain your app is running only on single-byte char sets with
> >7-bit ASCII, then you could speed things up even more by using
> >StrCompareAscii() and StrNCompareAscii() instead.
>
> The Str[N]CompareAscii routine should only be used if the text you're
> sorting is never displayed to the user - in that case you could use
> it on any text (regardless of the character encoding), since it's
> just doing a raw byte-by-byte comparison.
>
> Otherwise, you want to use locale-specific sorting as provided by the
> Txt[Caseless]Compare routine.
>
> -- Ken
>
> Ken Krugler
> TransPac Software, Inc.
> <http://www.transpac.com>
> +1 530-470-9200
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to