Re: Accessors
Re: Accessors
- Subject: Re: Accessors
- From: Shawn Erickson <email@hidden>
- Date: Thu, 8 Aug 2002 09:35:42 -0700
On Thursday, August 8, 2002, at 03:29 AM, Bill Cheeseman wrote:
on 02-08-08 2:03 AM, Shawn Erickson at email@hidden wrote:
- setSomeName: (SomeType*)newSomeName
{
if (newSomeName == _someName) return;
[_someName release];
_someName = [newSomeName copy];
}
I've noticed a couple of people testing for equality and returning in
the
first line, like this. My usual practice is to test for inequality,
then
fall through to the bottom if the test is false.
In "history" some processors are faster at checking inequality while
others are better at equality (this also deals with branch prediction)
but today this issue is irrelevant (actually for a long time now) .
Is there some advantage to the return? I've always thought it was just
a
matter of style.
In this example it is just a matter of style and done to be compact in
the macro.
I personally have no issue with multiple exit point in code if it makes
sense. For example I usually do parameter/precondition checking at the
beginning of method calls and return out or throw exceptions before I
get to the meat of the method. I do try to avoid having exit points
mixed in the guts of my method unless it is a return of some deep loop,
say to search for some object, etc.
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.