Re: Efficiently adding a bunch of items to an NSMutableArray

2010-09-22 Thread Ken Thomases
On Sep 22, 2010, at 05:46, Oleg Krupnov wrote: > It seems that the -addObjectsFromArray: method may be what I > need, but the docs do not make it clear if it's internally optimized > to do only a single memory re-allocation. I'll add my two cents: you should almost always use the method that dire

Re: Efficiently adding a bunch of items to an NSMutableArray

2010-09-22 Thread Quincey Morris
On Sep 22, 2010, at 05:46, Oleg Krupnov wrote: > I have a NSMutableArray and need to add a number of elements to it, > and their quantity I know in advance (in fact, they come from another > array). > > I think that if I add them one-by-one in a loop, the array will have > to reallocate its inter

Re: Efficiently adding a bunch of items to an NSMutableArray

2010-09-22 Thread Uli Kusterer
On Sep 22, 2010, at 2:46 PM, Oleg Krupnov wrote: > I think that if I add them one-by-one in a loop, the array will have > to reallocate its internal memory frequently. This seems inefficient. "I think" and "seems" are bad advice. What do Shark/Instruments say? Does it take long? Does this code r

Re: Efficiently adding a bunch of items to an NSMutableArray

2010-09-22 Thread Jean-Daniel Dupas
Le 22 sept. 2010 à 14:46, Oleg Krupnov a écrit : > Hi, > > I have a NSMutableArray and need to add a number of elements to it, > and their quantity I know in advance (in fact, they come from another > array). > > I think that if I add them one-by-one in a loop, the array will have > to realloca

Efficiently adding a bunch of items to an NSMutableArray

2010-09-22 Thread Oleg Krupnov
Hi, I have a NSMutableArray and need to add a number of elements to it, and their quantity I know in advance (in fact, they come from another array). I think that if I add them one-by-one in a loop, the array will have to reallocate its internal memory frequently. This seems inefficient. I'd lik