• 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: Getting record items of a sublist
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting record items of a sublist


  • Subject: Re: Getting record items of a sublist
  • From: Nigel Garvey <email@hidden>
  • Date: Sun, 30 Oct 2011 22:15:00 +0000

Christopher Stone wrote on Sun, 30 Oct 2011 11:50:00 -0500:

>On Oct 30, 2011, at 06:41, Nigel Garvey wrote:
>> This takes about 0.02 seconds:
>>
>>  repeat with i from 1 to (count theNameList)
>>    set theItem to myname of item i of my theNameList -- NB.
'theNameList'
>>is referenced (with 'my').
>>    set end of my theChooseList to theItem -- Ditto 'theChooseList'.
>>  end repeat
>
>______________________________________________________________________
>
>Hey Nigel,
>
>My, my.  That's a whopper of a difference.
>
>0.008 seconds here on my i7 MacBook Pro
>
>Outstanding little trick - any idea of why it works?

As I see Axel's already mentioned, it's to do with using a reference to
the list — or more accurately, using a reference to the list _variable_
in the reference to the item(s) being accessed:

  item i of listVariable of aScript -- NB. the 'of aScript' part.

If the list variable's a global, a property, or a run-handler variable,
you can reference it against the main script either with another
variable set to 'a reference to listVariable', or better still, by
placing 'my' in front of it in the source code. In a local situation,
such as within a handler, you can assign the list to a property of a
local script object and reference the items through that property of
that script object.

It's only worth doing if you're accessing the items of a large list a
large number of times.

The official reason for the speed gain used to be something along the
lines of it circumventing certain safety checks, but I've never been
entirely sure.

>One more thing.  Let me recommend the LapTime.osax for timing scripts ….

Thanks! I'll give it a try. Not being able to use GetMilliSec on my
Intel machine, I've been using André Berg's Unix executable "timetools".
It's good, but subject to the overhead with 'do shell script'.

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

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting record items of a sublist
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: Getting record items of a sublist
  • Next by Date: Re: Getting record items of a sublist
  • Previous by thread: Re: Getting record items of a sublist
  • Next by thread: Re: Getting record items of a sublist
  • Index(es):
    • Date
    • Thread