optimize: replace while loop by memcpy
[fw/openocd] / src / flash / nor / str9xpec.c
index 6fa66a09ca8300e8786d5a2e14daa06d08fd8192..0e095a30434e4e1ed4a09ec08538c69b8a242e32 100644 (file)
@@ -714,14 +714,9 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer,
        if (bytes_remaining)
        {
                uint8_t last_dword[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-               i = 0;
 
-               while (bytes_remaining > 0)
-               {
-                       last_dword[i++] = *(buffer + bytes_written);
-                       bytes_remaining--;
-                       bytes_written++;
-               }
+               /* copy the last remaining bytes into the write buffer */
+               memcpy(last_dword, buffer+bytes_written, bytes_remaining);
 
                str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);