• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
loop efficiency & messages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

loop efficiency & messages


  • Subject: loop efficiency & messages
  • From: Mark Dawson <email@hidden>
  • Date: Tue, 22 Mar 2005 11:57:14 -0800

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


  • Follow-Ups:
    • Re: loop efficiency & messages
      • From: Todd Blanchard <email@hidden>
    • Re: loop efficiency & messages
      • From: Thomas Davie <email@hidden>
    • Re: loop efficiency & messages
      • From: Ondra Cada <email@hidden>
    • Re: loop efficiency & messages
      • From: Guy English <email@hidden>
  • Prev by Date: NSPopupButtons and NSArrayControllers question and behavior
  • Next by Date: path question
  • Previous by thread: Re: NSPopupButtons and NSArrayControllers question and behavior
  • Next by thread: Re: loop efficiency & messages
  • Index(es):
    • Date
    • Thread