Re: loop efficiency & messages
Re: loop efficiency & messages
- Subject: Re: loop efficiency & messages
- From: Todd Blanchard <email@hidden>
- Date: Wed, 23 Mar 2005 03:55:37 -0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Not exactly on topic but getCount is a lousy name for a method in
objective C.
accessors are just the attrribute names ie count
mutators are setCount:
unless you want your code to look like it was done by a piker don't cha
know.
On Mar 22, 2005, at 11:57 AM, Mark Dawson wrote:
if I have a getter: -getCount { return mCount; }
How much of a difference are there between the following two loops?
int count = [self getCount];
for (i = 0; i < count; i++)
…
for (i = 0; i < [self getCount]; i++)
Does compiler optimize this similar to a C++ inline so that count is
just stored in a register, or does a message sequence happen each
time? If messages happen each time, is it a better habit to do the
first for loop (where the compiler should just keep count in a
register)? I realize that it may not make much difference with most
loops, but if there's a "better" way, I'd like to get into the habit
of typing the "better" code…
Thanks,
mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFCQVk5hullemWJdQ8RAng1AJ9TlKshQGnqIRqtaOv/QbdvZcA68gCgp1b5
6nJuXhI7jVJguxMpPjmm74Y=
=xvIO
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden