|
|
a strange non-optimization comment
NOTE: This comment (below) is _NOT_ something you should use to modify the original hint. I took a look at how you could ask Address Book to give you a list of people who have phones (using the AppleScript command 'whose'), rather than having to loop over every contact. Unfortunately (but not really that surprising), Address Book is MUCH slower at doing that filtering up front than it is at looping over each person separately. So, the code shown below is for informational purposes only - it would much the script much slower:
Now, this takes about 20 seconds to run on my Address Book database of about 1000 contacts. When I tested the original code, the loop-over-all-contacts takes about 1 second. I thought at first that it would be faster to just get the list of people you actually want, but, as is often the case in AppleScript, the 'whose' command fails amazingly here. I originally was going to post this alternative code without testing, but based on past experiences, I thought it would be good to know how well the original code ran. The result? Original code in the hint is 20 times faster. Wow. Aside: A similarly slow command that would get only people who have no phones:
AppleScript is a strange beast - this is by far not the strangest thing I've seen over the years. ---
http://www.danshockley.com |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|