Well, hopefully you'd code it up like:
for (int a = 0; a < 10; a++)
{
doSomething();
}
But otherwise, they're essentially the same. doSomething()'s execution will more
than dwarf the interation overhead. CodeWarrior *does* recognize the following
construct and optimizes for it:
long a = 10;
while (a-- > 0)
{
doSomething();
}
But I still doubt that you'd benefit from it.
-- Keith
"Nick Torenvliet" <[EMAIL PROTECTED]> on 06/21/2000 05:49:21 PM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: "Nick Torenvliet" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/HQ/3Com)
Subject: C++ loops
This is less a Palm question and more a C++ question but never the less here
goes,
I am reading a book by Hyman and Vaddadi called "Mike and Phani's Essential
C++ Techniques."
They often refer to loops structures that are coded something like this,
int a = 0;
int b = 10;
while(a < b)
{
a++;
doSomething();
}
Now if I was to code the same loop I would do somehting like this
for (int a = 0; a++ ; a < 10)
{
doSomething();
}
I am wondering if there is any speed advantage to be gained from using either
the former or the later loop type.
Nick Torenvliet
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/