title: If I have two functions copyij() and copyji(), to copy a 2048x2048 integer array, which one is faster and why?
body: <p>This is in C++, and I used the time command on Unix and found that copyij() was significantly faster.</p>
  
  <pre><code>void copyij(long int src[MSize][MSize], long int dst[MSize][MSize])
  {
    long int i,j;
    for (i = 0; i &lt; MSize; i++)
      for (j = 0; j &lt; MSize; j++)
        dst[i][j] = src[i][j];
  }
  </code></pre>
  
  <p>copyji() is similar, except the j loop is before the i-loop. </p>