lineOffset wildcard

Mark Wieder ahsoftware at sonic.net
Mon Apr 19 21:14:52 EDT 2021


> I'll try benchmarking this against Jacque's suggestion of matchChunk. 
> Filter is normally pretty fast, but I'll have to use the regex version, 
> and I'm not sure what the speed implications will be.

Benchmark result averages over 10 runs on a 2700-line script:

filter lines of script 2612.6ms
filter script          2572.1ms
matchChunk             2424.3ms

the code:

put "^local.*"&tLocal&".*" into tRegexString

put matchChunk(tScript, tRegexString, tStartPos, tEndPos) into tFound?
if tFound? then
    put the number of lines in char 1 to tStartPos of tScript into tLine
end if

filter tScript with regex tRegexString into tFoundScript
# alternate: no appreciable difference in timing
# filter tScript with "local*"&tLocal&"*" into tFoundScript
if tFoundScript is not empty then
    put lineoffset(tFoundScript, tScript) into tLine
end if

So matchChunk plus "the number of lines" is faster by ~150 milliseconds 
over 2700 lines of text than filter plus lineOffset.

-- 
  Mark Wieder
  ahsoftware at gmail.com




More information about the use-livecode mailing list