1
0

fwrite_le.c: optimize for FWRITE_LE_NO_MODIFICATION case

This commit is contained in:
Intel A80486DX2-66 2023-12-31 15:38:28 +03:00
parent ff5608e0d0
commit b3a635076b
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -49,9 +49,14 @@ size_t fwrite_le(void* ptr, size_t size, size_t count, FILE* stream) {
const size_t div_size = size >> 1; // divide by 2
for (size_t j = 0; j < div_size; j++) {
const size_t old_pos = i + j, new_pos = i + size - j - 1;
#if FWRITE_LE_NO_MODIFICATION
bytes[old_pos] = ptr[new_pos];
bytes[new_pos] = ptr[old_pos];
#else
uint8_t temp = bytes[old_pos];
bytes[old_pos] = bytes[new_pos];
bytes[new_pos] = temp;
#endif
}
}