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 directly 
describes the operation you're trying to perform at a high level 
(-addObjectsFromArray:, in this case).  If there's a way that you could imagine 
breaking the high-level operation down into low-level operations, then that 
same technique is available to the implementors of the high-level routine.  
Plus, they may have techniques available to them that you don't -- they have 
access to the internals, they can put more resources into optimization, etc.  
By choosing the high-level operation, you give the implementation the greatest 
freedom to take advantage of advanced techniques.  If you choose the low-level 
techniques, you curtail the possibilities.

Also, the high-level approach will be less code, less error-prone, easier to 
read and understand, etc.

It's almost always the right choice.

And, as others have said, you're probably optimizing prematurely.  So, all of 
the other considerations probably swamp any benefit from caring about the 
performance of this single operation.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to