Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :-).

like image 812
jasondinh Avatar asked Apr 19 '12 08:04

jasondinh


1 Answers

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.

like image 173
fbernardo Avatar answered Nov 09 '22 09:11

fbernardo