Re: Arc and autorelease
Re: Arc and autorelease
- Subject: Re: Arc and autorelease
- From: David Duncan <email@hidden>
- Date: Thu, 24 May 2012 09:51:06 -0700
On May 24, 2012, at 1:14 AM, Gerriet M. Denkmann wrote:
> Without Arc, this:
>
> NSString *s = [ [ NSString alloc ] initWithFormat: ...];
> [ someCollection addObject: s ];
> [ s release ];
>
> is clearly more efficient (because not using autoreleasepools) than:
>
> NSString *s = [ NSString stringWithFormat: ...];
> [ someCollection addObject: s ];
>
> But what about Arc?
> Is the compiler clever enough to make both versions equally efficient?
> Or should one still avoid using the convenience method stringWithFormat: ?
As a rule, ARC tries to keep objects out of the local autorelease pool, and can usually succeed at that even when working with code that is not itself compiled under ARC. I would use whichever method makes sense to you and only worry about high watermark issues if you discover a performance issue.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden