On Aug 20, 2008, at 12:42 PM, Dave wrote:
The copy operation here, copies that data from one string to a newly allocated string, right?
Only if it's mutable. If it's immutable, it's most likely that copy will just do the same thing as retain - since that object isn't going to change, there's little point in making a whole copy of it, so Apple does basically the same optimization that you were trying to do.
For this reason, it's usually best just to use copy - most of the time there will be no additional allocation since it's just doing the same thing as retain, and when there *is* an additional allocation, it's usually when you actually need it - for example, you don't want some other object to accidentally mutate some object that's in your object's internal state, so if you're given a mutable object, the best thing to do is make a copy so that you can know that the object won't change behind your back.
Charles _______________________________________________ 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 [EMAIL PROTECTED]