gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] ISO Strings.Equal relatively slow


From: Gaius Mulley
Subject: Re: [Gm2] ISO Strings.Equal relatively slow
Date: Mon, 04 Apr 2011 16:56:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

SiTex Graphics <address@hidden> writes:

> Hi Gaius,
>
> I recall an earlier thread on this topic, but since it's been a while,
> I'll start a new one.
>
> An end-user submitted a case where Strings.Equal became a bottleneck
> for our application.  A routine that normally does a few hundred
> comparisons was performing millions, and the Equal comparision slowed
> our app to a crawl.  Interestingly, this case didn't noticably affect
> the performance of the XDS and Stonybrook builds of our application.
> I've modified our code to avoid this case, but it still seemed like a
> good idea to try to improve the performance of Equal.
>
> Our typical usage is searching a list for a match, and inequality is
> by far the most common result.  The code below is written with that
> scenario in mind, and it performs much better in my tests than the
> existing Equal routine.  Perhaps you'll consider replacing the
> existing code with the source below (or perhaps an even faster
> version)?
>
> Thanks,
> Scott
>
>
> PROCEDURE Equal (a, b: ARRAY OF CHAR) : BOOLEAN ;
> VAR i : CARDINAL ;
> BEGIN
>   i:=0;
>   LOOP
>     IF a[i]<>b[i] THEN RETURN FALSE; END;
>     IF a[i]=CHR(0) THEN RETURN TRUE; END;
>     INC(i);
>     IF i>HIGH(a) THEN RETURN (HIGH(a)=HIGH(b)) OR (b[i]=CHR(0)); END;
>     IF i>HIGH(b) THEN RETURN a[i]=CHR(0); END;
>   END;
> END Equal;

Hi Scott,

many thanks for the bug report - yes indeed the current implementation
is slow.  I've recoded it now - and will push it out to the cvs once
I've run the regression tests,

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]