• 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: 'my' problem is your problem: it chokes without 'my'! BUG
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'my' problem is your problem: it chokes without 'my'! BUG


  • Subject: Re: 'my' problem is your problem: it chokes without 'my'! BUG
  • From: "Nigel Garvey" <email@hidden>
  • Date: Tue, 25 Jan 2011 21:21:04 +0000

Harald E Brandt wrote on Tue, 25 Jan 2011 18:39:58 +0100:

>property theData : {}
>set theFile to (choose file with prompt "Choose tab-delimited file:")
>
>set theParas to paragraphs of (read theFile as text)
>repeat with aRow in theParas
>	set end of my theData to {contents of aRow} -- using 'my' is absolutely
>vital for large files!!
>end repeat
>
>If run with a text file of 10 000 lines, it takes about 12.5 seconds on a
>MacBook Pro 2.2 GHz Core 2 duo, 4 GB, SSD 200 GB.
>If you remove the 'my', it won't terminate!  Nasty!
>
>(Ok, I didn't wait for hours, but for minutes.)

>If run on a 1000-line file, it works better: it will terminate less than
>0.2 seconds with the 'my', and about 0.7 seconds without the 'my'.
>
>So, despite no handler or script object is involved, the 'my' is needed,
>and it is also needed if you wrap it into a handler.

It's a fairly well understood AppleScript list phenomenon. Putting 'my'
in front of a list variable name produces a reference to that variable.
It's the same reference produced by 'set theDataRef to a reference to
theData', only it's compiled into the code rather than being stored in a
variable. Using this in references to the list's items and properties
greatly speeds up access to those items and properties.

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: 'my' problem is your problem: it chokes without 'my'! BUG
      • From: Harald E Brandt <email@hidden>
  • Prev by Date: event log history window
  • Next by Date: Re: Is Image Disk Trash Empty?
  • Previous by thread: 'my' problem is your problem: it chokes without 'my'! BUG
  • Next by thread: Re: 'my' problem is your problem: it chokes without 'my'! BUG
  • Index(es):
    • Date
    • Thread