Re: A faster offset...
Re: A faster offset...
- Subject: Re: A faster offset...
- From: Emmanuel <email@hidden>
- Date: Thu, 6 Sep 2001 16:32:45 +0200
At 9:29 +0200 6/09/01, David Lloyd wrote:
>
--snippet 1-----
>
>
repeat 500 times
>
copy (offset of "x" in "asdxasd") to o
>
end repeat
>
>
--snippet 2-----
>
>
repeat 500 times
>
copy offsetInString("x", "asdxasd") to o
>
end repeat
>
>
on offsetInString(theItem, theString)
>
if theItem "" then
>
set AppleScript's text item delimiters to theItem
>
copy (text items of theString) to theItems
>
set AppleScript's text item delimiters to ""
>
if (count of theItems) = 1 then
>
return 0
>
else
>
return (length of item 1 of theItems) + 1
>
end if
>
else
>
return 0
>
end if
>
end offsetInString
-- {6.35, 4.38} (seconds for 5000 iterations)
Only a small 2 factor here?
Emmanuel