Comparing big lists

Dave Cragg dcragg at lacscentre.co.uk
Sun Apr 28 05:07:00 EDT 2002


At 11:32 pm +0000 27/4/02, jbv wrote:
>I'm wondering : what is the most expensive ?
>
>Is it lineoffset, or is it :
>     put j & tab & line thisLine of bigList  & return after mergedList
>
>I vaguely recall some discussion about adding new lines at the end of
>a variable inside a loop, and the loop getting slower & slower...
>I'm even pretty sure it was already a problem in HC and/or in OMO...
>

It think you'll find adding stuff at the end of a variable extremely 
fast using "put x after y". However, the "line thisLine of bigList" 
part will get progressively slower as the value of thisLine 
increases.  This is why the general  advice is to use "repeat for 
each" where possible and avoid using incremented chunk expressions 
which have to count through the data each time. However, going back 
to the original example, if you don't expect to find many matches, 
that part may not be so costly. On the other hand, lineOffset will 
get called for each line, making it fairly expensive.

So, if possible, in large loops:

-- use "repeat for each" (or "split" as Scott suggested)
-- use "put x after y"
-- avoid using "line n of y"
-- avoid using lineOffset

Cheers
Dave Cragg



More information about the metacard mailing list