SC, Rev,and RB speed test
Monte Goulding
monte at sweattechnologies.com
Sat Apr 17 21:23:15 EDT 2004
woops... uncomment a few lines in there to get what I intended:
local sMatch,sOldMatch
on mouseUp
local tFind,tSearch,tLine,tMatchList, \
tTicks,tList,k1,k2,k3,inWord,inLine ,MatchList
set cursor to watch
put empty into field "TheResults"
put ticks() into tTicks
put field "targetText" into tMatchList
put field "SearchTextList" into tList
if tMatchList <> sOldMatch then
put tMatchList into sOldMatch
-- stripping quotes from both sets saves problems with single quotes
-- or with quoted strings being treated as a word
replace quote with empty in tMatchList
-- Prepare the target text in all consecutive triplet groups
repeat for each word inWord in tMatchList
put k2 into k1
put k3 into k2
put inWord into k3
put true into sMatch[k1 && k2 && k3]
end repeat
end if
replace quote with empty in tList
repeat for each line inLine in tList
if the number of words of inLine = 3 then
put true into tSearch[inLine]
else
--Do a simple search for groups other than three words
if inLine is in tMatchList then
put inLine & return after MatchList
end if
end if
end repeat
-- Now for the Revolution!
intersect tSearch with sMatch
put keys(tSearch) & cr & MatchList into field "TheResults"
put ticks()-tTicks && "ticks" &cr after fld "SpeedRecords"
end mouseUp
Results = 40 ticks on first run (12 ticks on subsequent runs)
So this could be a valuable saving if you change the search list but keep
the text your searching. I'll now spend a few mins working out how to best
handle the second half of the preparation and get back to the list ;-)
Cheers
Monte
More information about the use-livecode
mailing list