I have been using Objective-C recently, and, coming from the C++ world, I don't get the point of specifying a capacity for the native Objective-C collections.
In C++, containers can be either filled with objects or reference types (e.g., reference wrappers or pointers), therefore specifying an initial capacity makes sense, because pre-allocating memory for a sequence of large objects can be a big performance improvement. However, in Objective-C, collections can only contain references to dynamically allocated objects, i.e., pointers. As a consequence, I wonder what's the performance advantage of specifying a capacity if, in the worst case, just pointers will need to be copied if the size of the collection is to exceed the original capacity.
Clearly, there is a lack in my understanding of the memory model, so what am I missing?