Guest
31st December 2006, 17:42
Learn to use a profiler and then test different approaches. Or learn assembler and inspect the generated code.
IanB
1st January 2007, 08:58
Mythical code! You know plugh->GlobalSomething() is invariant within the loop, the compiler cannot tell.for (i=0;i<h;i++) {
for (j=0;j<w;j++){
if (plugh->GlobalSomething()) {
d[i,j]=s[i,j]+1;
}
else {
d[i,j]=s[i,j]-1;
}
}
}orif (plugh->GlobalSomething()) {
for (i=0;i<h;i++) {
for (j=0;j<w;j++){
d[i,j]=s[i,j]+1;
}
}
}
else {
for (i=0;i<h;i++) {
for (j=0;j<w;j++){
d[i,j]=-s[i,j]-1;
}
}
}Which do you think a) is faster and b) is smaller.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.