title: Is there any code Optimization method for the following c++ program
body: <pre><code>        BYTE * srcData;
          BYTE * pData;
  
          int i,j;
          int srcPadding;
  
                      //some variable initialization
  
          for (int r = 0;r &lt; h;r++,srcData+= srcPadding)
          {
              for (int col = 0;col &lt; w;col++,pData += 4,srcData += 3)
              {
                  memcpy(pData,srcData,3);        
              }
          }
  </code></pre>
  
  <p>I've tried loop unrolling, but it helps little.</p>
  
  <pre><code>        int segs = w / 4;
          int remain = w - segs * 4; 
  
          for (int r = 0;r &lt; h;r++,srcData+= srcPadding)
          {
              int idx = 0;
              for (idx = 0;idx &lt; segs;idx++,pData += 16,srcData += 12)
              {
                  memcpy(pData,srcData,3);
                  *(pData + 3) = 0xFF;
                  memcpy(pData + 4,srcData + 3,3);
                  *(pData + 7) = 0xFF;
                  memcpy(pData + 8,srcData + 6,3);
                  *(pData + 11) = 0xFF;
                  memcpy(pData + 12,srcData + 9,3);
                  *(pData + 15) = 0xFF;
              }
              for (idx = 0;idx &lt; remain;idx++,pData += 4,srcData += 3)
              {
                  memcpy(pData,srcData,3);
                  *(pData + 3) = 0xFF;
              }
          }
  </code></pre>