First sentence: I don’t have any idea what you are saying here - “as I strike an existing Client” ??
Second sentence: It isn’t clear to me whether you should be doing this with arrays at all. Trying to get a handle on what you’re trying to accomplish with your project is difficult without more concrete examples of your files. It sounded like, from your very first post on this project, that you’re starting with many files with text not arrays. Are you converting them to arrays (or lists) first? Maybe string searching techniques or an NSScanner might be a better approach.
Third sentence: You shouldn’t be doing anything with NSDecimalNumbers in ASOC (that’s an Obj-C thing)
Fourth sentence: “offset of an instance of a particular Client” I don’t know what you mean by this either. It isn’t hard to get the offset of a known string within a larger string, but I don’t know if that’s what you’re trying to do here.
I can try to help you convert some of your code to Objective-C, but in the absence of a good idea of the overall structure of your project, I don’t know if that would be useful. The code you just posted has four things that come from the outside of that code snippet: TempWholeList, separateOutClient(paragraphCycle), theClientList, and theClientListNumberKeeper. I would have to pass these all in to the Obj-C method, and I would have to know what they are to do that. I could offer a lot more useful help if you could provide an example of one of your files (with fake data if need be) and a clear idea of what output you want from the project. You can contact me by email if you want to do this offline.
Then we need to count how many times each Client occurs. And this must be done in between set dates if necessary.
With 48,000 individual entries, over 4600 Clients, everything is slow. The code that you did for me is taking about 200 seconds, but I thought it might be faster if…
As I loop through each paragraph, in each file, I add any new clients to an array. (was originally a list).
I simultaneously add a 1 to a matching array (which also once was a list).
As I find a Client that already exists in the array, I then want to add 1 to the matching number array.
To add that number 1, I have to loop through the Client array until I find a match, then add 1 to the matching number array
Looping through the clients to get a match is slow, but as the loop is the slowest part, i wondered about replacing it with ObjC code.
The above looping adds about 2000 seconds to a 2060 second search, so if I could reduce it to 2000/270 seconds it would be a huge difference
Why not? NSMutableArray is an Objective-C thing too. So you should keep those things together if you want to improve speed. Getting an object from an NSMutableArray, convert it to an applescript class, increment the value, convert the value back to an cocoa object and place it in the array seems for me unnecessary. So when using NSDecimalNumber you can void these types of overhead which results in a faster program. If he wants the value later back to applescript he can use doubleValue to get it back to applescript.