MACSCRPT Archives

February 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Deivy Marck Petrescu <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 5 Feb 2009 18:03:26 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
On Feb 5, 2009, at 5:55 PM, Shane Stanley wrote:

> On 6/2/09 7:13 AM, "Ryan Wilcox" <[log in to unmask]> wrote:
>
>> I believed the second one would be much faster than the first as well
>
> Why? The first is just modifying a string; the second is modifying a  
> (large
> and growing) list.
>

... modifying a string and then creating a huge list.
But still, the second is playing with a list from the outset.
I believe a while ago Chris Nebel put a god explanation on why lists  
require more "work" in the Apple AppleScript list.
If one does away with the need of manipulating a list but instead uses  
a reference to the list then the situation changes dramatically:

set a to "b"
set c to {}
--
set t0 to (current date)
repeat 10000 times
	set a to a & "a"
end repeat
set b to text items of a
set t1 to (current date) - t0
--
set t2 to (current date)
repeat 10000 times
	set end of (a reference to c) to "a"
end repeat
set t3 to (current date) - t2
--
{t1, t3}

---{1,0} OMM



Deivy Petrescu
[log in to unmask]

ATOM RSS1 RSS2