Frankly, the whole mutable/immutable thing seems confusing at
times. For
example, what's the point of specifying a capacity when creating a
mutable
CF object? I've never been able to detect a performance different
when
specifying a maximum capacity. Do the immutable variants offer any
advantages over their mutable counterparts?
For the same reasons that you'd specify a starting capacity when
creating a hash table, or call reserve on a vector, etc. Everything
will behave the same, but fewer trips into the allocator and fewer
memcpy's. This might not be a significant win for some types of
code, but for others it may be quite important.
Unlike most vector implementations, the maxLength field in
CFStringCreateMutable() creates a hard bound upper limit. The
mutable string can never be larger than the size passed in. If
something happens that causes the size to be increased beyond the
upper bound, an assertion is raised.
If you can guarantee that the string will never grow beyond the hard
limit, then it can be a nice optimization. Otherwise, I consider it
to be a nice trap that will appear when I least expect it.
Adin Hunter Baber
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden