Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Which loop is faster?

Name: Anonymous 2012-01-16 8:59


for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[I][J]);

or

for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[J][I]);

???

Name: Anonymous 2012-01-16 9:40

>>6
Not that it matters when it is a separate statement, such as above, the compiler (assuming you use one) should be able to optimize it. But at least for IA32/IA64, int var = ++i; is fewer instructions than int var = i++;

Deal with it, kid

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List