Re: Can I speed this up, please?
Re: Can I speed this up, please?
- Subject: Re: Can I speed this up, please?
- From: Shane Stanley <email@hidden>
- Date: Fri, 22 May 2015 13:51:30 +1000
On 21 May 2015, at 8:35 pm, Brian Christmas <email@hidden> wrote:
>
> Is it possible to re-code the handler in ObjC to speed it up?
It is. But before you start, how fast do you want it?
The reason I ask is because you're going from one extreme -- plain AppleScript -- to the other -- Objective-C -- without considering the middle ground of AppleScriptObjC. So unless the answer to the previous question is "lightning fast", and given that you don't know Objective-C and it's a convoluted bit of processing, you might start with AppleScriptObjC.
For example, you're reading the file in a Finder block, and you're using delimiters. Last I tested, that's about the slowest option going. You could use NSString's + stringWithContentsOfURL:encoding:error: method, then componentsSeparatedByString:.
If you can then work on the resulting array as much as possible, rather than coercing it to an AppleScript list, it will be much quicker.
If it were me, I'd add something like my ASObjcExtras, or better still BridgePlus, framework to the project. Then you could use SMSForder's subarraysFrom:(NSArray *)array groupedBy:(NSNumber *)aNumber error:(NSError *__autoreleasing *)outError method to make sublists of 52 items, which is what I think you're repeating through. And then you could use its (NSArray *)subarraysIn:(NSArray *)array sortedByIndexes:(NSArray *)indexes ascending:(NSArray *)order sortTypes:(NSArray *)types error:(NSError *__autoreleasing *)outError method to sort them all by date. That would probably simplify the rest of the process (although it's hard to tell because you don't document the exact file format anywhere).
In short, (a) if you want Objective-C code, it's probably of a level of complexity that you really need to consider hiring someone (apart from anything, the approach would, I suspect, be quite different), and (b) using AppleScriptObjC would probably speed it up significantly, but you'd still want to change your approach.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden