pea
developer
Hi all,
When I do a loop, is the condition evaluated once at the start, or for every iteration? which of these is best:
or
Conversly, is it more expensive to reference struct members than a variable directly? Which of these is best:
or
Thoughts appreciated!
When I do a loop, is the condition evaluated once at the start, or for every iteration? which of these is best:
Code:
for (i=0; i<someFunction(); i++){
// Do stuff
}
Code:
x = someFunction();
for (i=0; i<x; i++){
// Do stuff
}
Conversly, is it more expensive to reference struct members than a variable directly? Which of these is best:
Code:
a = b[someStruct->member1->member2];
b->x = someStruct->member1->member2;
Code:
s=someStruct->member1->member2;
a = b[s];
b->x = s;
Thoughts appreciated!