commit 678019e771e8ab6a576027916971dbe0cf61fc3c parent b022ad91a3cde32a50666e27064d214b291f413e Author: Frederic Cambus <fred@statdns.com> Date: Thu, 21 Feb 2019 23:09:44 +0100 Avoid doing an addition for each loop step to calculate offset. Diffstat:
M | pcx2gba.c | | | 8 | +++++--- |
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/pcx2gba.c b/pcx2gba.c @@ -96,14 +96,16 @@ int main(int argc, char *argv[]) { pcx_buffer_size = (pcx_header.x_max+1)*(pcx_header.y_max+1); pcx_buffer = malloc(pcx_buffer_size); - while (loop < input_file_size-768-128) { - current_byte = input_file_buffer[loop+128]; + loop = PCX_HEADER_LENGTH; + + while (loop < input_file_size-768) { + current_byte = input_file_buffer[loop]; if (current_byte > 192) { run_count = current_byte-192; for (run_position = 0; run_position < run_count; run_position++) { - pcx_buffer[offset+run_position] = input_file_buffer[loop+128+1]; + pcx_buffer[offset+run_position] = input_file_buffer[loop+1]; } offset += run_count; loop += 2;