>It would be interesting to run a test to find out.
Here's the results (1.25MHz G4):
# Lines = 1000
-- "starting test"
-- "no delete"
-- "starting test"
-- "no delete"
-- "no delete = 1183"
-- "delete"
-- "delete = 78"
# Lines = 10000
-- "starting test"
-- "no delete"
-- "no delete = 126465"
-- "delete"
-- "delete = 10661"
Test times in milliseconds.
So, you can see that the delete method is well over an ORDER OF MAGNITUDE
faster. Optimizing the insert into the new string would speed the whole
thing up even more, especially when the number of lines gets large.
Sometimes, being a Lingo old guy has it's advantages, since on old
computers, we had to do this kind of optimization routinely...
Test Code:
on test
-- fill tText
put "starting test"
tText = ""
repeat with i = 1 to 1000
tText = tText & "This is some filler" & RETURN
end repeat
tLines = 1000
put "no delete"
start = the milliseconds
newString = EMPTY
temp = tText
repeat with i = 1 to tLines
aLine = temp.line[tLines]
--modify aLine
put aLine after newString
end repeat
put "no delete = " & string(the milliseconds - start)
put "delete"
start = the milliseconds
newString = EMPTY
temp = tText
repeat with i = 1 to tLines
aLine = temp.line[1]
--modify aLine
put aLine after newString
delete line 1 of temp
end repeat
put "delete = " & string(the milliseconds - start)
end test
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]