Re: 3 obj-c/cocoa beginner q's
Re: 3 obj-c/cocoa beginner q's
- Subject: Re: 3 obj-c/cocoa beginner q's
- From: Raymond Fischer <email@hidden>
- Date: Tue, 25 Mar 2003 14:43:17 -0800
On Tuesday, March 25, 2003, at 07:59 AM, Ben Dougall wrote:
Most optimum I can think of (beware of C++isms though). Unless you
really need to traverse upwards.
for(int i([myArray count] - 1); i >= 0; --i)
{
...
}
oh yeah that's good - doesn't even use the extra variable. thanks.
As an aside, there is usually nothing wrong with using an "extra"
variable.
Compilers are smart enough to 1) keep variables in registers, and 2)
figure
out where a variable is used.
That said, counting down to zero is usually best if you don't need to
count
up because tests against zero are faster than comparisons. (Be careful
of
unsigned ints). But if you have a counter variable and a limit variable
it
doesn't really matter how you declare them. Readability of code is
really
the only consideration.
----
Ray Fischer
Adobe Systems
_______________________________________________
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.