NSMutableArray: is it faster to remove all objects or to init a new NSMutableArray?

cocoa, nsmutablearray, objective-c

Solution

It's faster to remove all objects. The costly thing about a NSMutableArray is extending it's internal list when it runs out of capacity.

Have a look at this blog post.

Problem

Even though this has minimal impact on my code right now I would like to understand if an operation is more costly than the other :-).

Original source