Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a question about accessing list items through a reference



Thanks for you response.

> <script>
> script AScript
> 	property a_list : {1, 2}
> end script
>
> set l to AScript's a_list -- this is the "get"
>
> repeat with ref_to_item in l
> 	set contents of ref_to_item to 3
> end repeat
> </script>
>

Unfortunately above script is slow.

Indirect access to a list is important for the performance.

on run
	set num_list to {}
	repeat with n from 1 to 1000
		set end of num_list to n
	end repeat
	
	script AScript
		property a_list : num_list
	end script
	
	set l to AScript's a_list -- this is the "get"
	set time1 to GetMilliSec
	repeat with ref_to_item in l
		if ref_to_item > 100 then
			set contents of ref_to_item to 3
		end if
	end repeat
	
	set time2 to GetMilliSec
	set l to a reference to AScript's a_list
	repeat with ref_to_item in l
		if ref_to_item > 100 then
			set contents of ref_to_item to 3
		end if
	end repeat
	
	set time3 to GetMilliSec
	{time2 - time1, time3 - time2} -- result : {343.0, 41.0} msec
end run

=======================================================
 Tetsuro KURITA
  E-mail: email@hidden
  http://homepage.mac.com/tkurita/scriptfactory/en/
=======================================================


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: a question about accessing list items through a reference (From: Tetsuro KURITA <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.