Re: accessor question
Re: accessor question
- Subject: Re: accessor question
- From: sinclair44 <email@hidden>
- Date: Thu, 27 Feb 2003 16:42:49 -0500
On 2/27/03 4:31 PM, "Jonathan E. Jackel" <email@hidden> wrote:
>
This doesn't sound right to me.
>
>
First, you are assuming that the only time you use the object is to get its
>
myValue. There could be a hundred different ivars that are recalculated in
>
[self recalculate], and the object would give you the wrong value for them
>
after [self setMyValue] unless you first ask for myValue.
>
>
Second, it's no faster. It seems like it would be very slightly slower.
>
You are merely delaying the [self recalculate], but when it happens it will
>
take just as long. Plus, you are taking the time to set an extra variable
>
and perform an extra conditional.
>
>
Jonathan
That depends on the situation. In one of my programs, a box-and-wisker plot
maker (command-line), many -addNumber:'s are called (usually 10-15) before
-leastValue, -firstQuartile, etc. are called. All of the assessors also call
-recalc. It's much faster and only a little harder in this case.
However, if there's only 1 -setMyValue before -myValue, or if there's lots
of ivars, etc. then my way is harder/slower.
--
-- sinclair44
[self becomeWorldDictator];
- (void)becomeWorldDictator
{
[[world currentLeaders] assassinate];
[[world citizens] terrorize];
[world setCurrentLeaders:[NSArray arrayWithObject:self]];
}
_______________________________________________
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.