NPR puzzle

Alex Tweedly alex at tweedly.net
Wed Jul 20 16:26:57 EDT 2005


Lynch, Jonathan wrote:

>Interesting - so 'is not in' was actually faster than lineoffset! Is
>that always the case?
>
>What if you use this:
>
>If matchtext(Gorp,AnElement) = false then...
>  
>
I'd expect that to be slow - matchtext is going to invoke a general 
purpose regex handler - fast for what it does, but slow compared to 
simpler code that just does exact matches on strings.

It's unsurprising that "is not in" would be faster than "lineoffset"m 
because "is in" (or "is not in") can use string searching algorithms, 
which have been extensively studied and optimized, whereas lineoffset 
must either do
  - string search followed by a count of the number of cr's
or
  - loop through the lines, doing a string search within each.

Either way, the simple string search would normally be faster - but I 
wouldn't say "always" faster, there's bound to be some corner case where 
it isn't.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005




More information about the use-livecode mailing list