• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating list references in handlers. Bad code or bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating list references in handlers. Bad code or bug?


  • Subject: Re: Creating list references in handlers. Bad code or bug?
  • From: Paul Skinner <email@hidden>
  • Date: Mon, 17 Sep 2001 10:11:57 -0400

on 9/14/01 6:38 PM, Victor Yee wrote:

> On Fri, 14 Sep 2001 17:17:12 -0400, Paul Skinner wrote,
>
>> I was playing around with a vanilla, non-recursive 'entireContentsOf'
>> handler and I wanted to get the speed benefits of using references to lists.
>> Thus my first post.
>
> Are you sure there are speed improvements using "reference to" in your
> handler?
>
> Maybe it's just me, but it seems the same without.
>
> Victor

I believe you are correct. This form of reference isn't an object reference
and doesn't get any benefit of data sharing.

And I also suspect that this form also isn't an object reference but a
reference expression...

> on TestRef(theRef)
> item 1 of (get contents of theRef)
> end TestRef
>
> on Testit()
> set theVar to {"it works"}
> set theRef to a reference to (get theVar)
> TestRef(theRef)
> end Testit
>
> Testit()

I think that the ASLG indicates this difference on p.212. I was happy to
get my example working and didn't test for efficacy.
I believe that once you use an evaluation statement in targeting the
reference you have created a reference expression. When I created an actual
hard-coded list to target my reference, I created a reference expression. In
order to use an object reference the target must be an applescript object.
In my case it would have had to been a variable that held a list. In Yours,
it would have had to be a reference to theVar and not a reference to the
value that is held within theVar which is returned as the result of
'get'ing theVar.

I modified Apple's example from p.205 of the ASLG to test my theory.

Original code in ASLG...
-- bigList is a list of 4,000 integers
set bigListRef to a reference to bigList
set numItems to 4000
set t to (time of (current date))
repeat with n from 1 to numItems
item n of bigListRef
end repeat
set total to (time of (current date)) - t
total --result: 1 second (time may vary)

Modified with the 'get'
-- bigList is a list of 4,000 integers
set bigListRef to a reference to (get bigList)
set numItems to 4000
set t to (time of (current date))
repeat with n from 1 to numItems
item n of bigListRef
end repeat
set total to (time of (current date)) - t
total --result:around 30 seconds.


DISCLAIMER: I've had only half a cup of coffee and only looked at this
thread for 5 minutes since my roadrunner connection has been waterlogged all
weekend. : (

--
Paul Skinner


References: 
 >Re: Creating list references in handlers. Bad code or bug? (From: Victor Yee <email@hidden>)

  • Prev by Date: Re: Creating list references in handlers. Bad code or bug?
  • Next by Date: Re: acceptable hardloop
  • Previous by thread: Re: Creating list references in handlers. Bad code or bug?
  • Next by thread: Re: Creating list references in handlers. Bad code or bug?
  • Index(es):
    • Date
    • Thread