Immutables copied are just retained and returned, and mutableCopied are COW.

Mutables copied generates COW.

That would be the fastest way implementing that.

* COW = copy on write

On Apr 27, 2014, at 17:06, John McCall <rjmcc...@apple.com> wrote:

> On Apr 27, 2014, at 2:00 AM, Dave <d...@looktowindward.com> wrote:
>> A long time back, I remember reading something about the way in which copy 
>> and mutableCopy are implemented. I think basically it said that:
>> 
>> someObject = [someOtherObject copy];
>> 
>> or 
>> 
>> someObject = [someOtherObject mutableCopy];
>> 
>> Wouldn’t necessarily allocate any extra data storage. I’ve been searching 
>> for it to refresh my memory, but I can’t see to find it anywhere. Does 
>> anyone know if this document or something like it exists somewhere?
> 
> I don’t know if there’s a document, and like a lot of things with ObjC the 
> actual guarantees are pretty weak, but implementations of these methods on 
> immutable types have been turning into essentially “return [self retain];" 
> for quite some time.  But that’s when the actual dynamic type is 
> guaranteed-immutable, e.g. something constructed as an NSArray, not just 
> something that’s immutable by convention, e.g. an NSMutableArray that you’re 
> passing around as an NSArray.
> 
> John.
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com
> 
> This email sent to xcvi...@me.com

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to