Subject: | |
From: | |
Reply To: | |
Date: | Thu, 5 Feb 2009 18:03:26 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
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]
|
|
|