Re: verify input parameter of init method and return nil before invoke [super init]
Re: verify input parameter of init method and return nil before invoke [super init]
- Subject: Re: verify input parameter of init method and return nil before invoke [super init]
- From: Greg Parker <email@hidden>
- Date: Wed, 30 Jan 2013 01:07:35 -0800
On Jan 30, 2013, at 12:42 AM, Charles Srstka <email@hidden> wrote:
> On Jan 30, 2013, at 1:25 AM, Greg Parker <email@hidden> wrote:
>> Name the method `new...` instead of `create...`. Otherwise you do suffer an autorelease penalty with ARC. (`create...` is not one of the names that ARC assumes will return a retained result.)
>
> Huh? I thought ARC generated objc_autoreleaseReturnValue in this case, which peeks up the stack to see if the caller is calling objc_retainAutoreleasedReturnValue on it, and refrains from autoreleasing the object if it does.
It does. All of that is relatively inexpensive, but still has a cost. Simply passing along the retained value as returned by -init... is free. (Ideally, +new... tail-calls -init...)
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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