I'm working at the audio buffer level, mixing audio signals created by a colleciton of objects. Since I'm looping through these objects at 44.1khz, efficiency is crucial. Is there any difference in the efficiency of iterating over an NSArray vs a C array of pointers? How about NSMutableArray?
Is there any difference in the efficiency of iterating over an NSArray vs a C array of pointers?
Yes. Iterating directly over a C array will be faster.
Most apps don't need to worry about this and should look elsewhere for performance gains. But if, in your app, this function runs 44,100 times per second, you probably should micro-optimize it (after, of course, making sure that it does as little as possible—that is, only the things you absolutely need to do 44,100 times per second).
How about NSMutableArray?
Vs. an NSArray? No difference that you can rely on or should care about.
The NSFastEnumeration protocol defines -countByEnumeratingWithState:objects:count: which uses a C array for iteration of NSArrays, NSMutableArrays, and any other collection objects that conform to it, avoiding a call to -objectAtIndex: each iteration. Use performance analysis to determine which is the fast enough solution.