Re: Slow vs faster
Re: Slow vs faster
- Subject: Re: Slow vs faster
- From: "Nigel Garvey" <email@hidden>
- Date: Sat, 8 Jan 2011 10:21:09 +0000
Luther Fuller wrote on Thu, 06 Jan 2011 13:55:04 -0600:
>on recursivehandler(folderAlias)
> tell application "Finder"
> -- open window of folderAlias
> -- do lots of stuff to window of folderAlias here
> -- then ...
>
> copy (sort folders of folderAlias by name) to folderList
> repeat with innerFolder in folderList
> select innerFolder
> my recursivehandler(innerFolder) -- and many other parameters
> end repeat
>
> -- close window of folderAlias
> end tell
>end recursivehandler
>
>For no good reason, I modified the code to this ...
>
>on recursivehandler(folderAlias) -- and many other parameters
> tell application "Finder"
> -- open window of folderAlias
> -- do lots of stuff to window of folderAlias here
> -- then ...
>
> copy (sort folders of folderAlias by name) to folderList
> repeat with i from 1 to (count items of folderList)
> set innerFolder to (item i of folderList) as alias
> select innerFolder
> my recursivehandler(innerFolder) -- and many other parameters
> end repeat
>
> -- close window of folderAlias
> end tell
>end recursivehandler
>
>Now it runs noticeably faster. (but still not blazing fast)
>But, why?
I found the second version faster too. At first I assumed it was because
of the different kinds of repeat, but the major contributor seems to be
the coercion to alias in the second version. Remove it from the second
version, or introduce it into the first, and they run at very nearly the
same speed.
This is quite surprising. I wouldn't expect the Finder to be able to
handle aliases faster than its own references, let alone with the
coercion time included.
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