Commit 94fb56f2 authored by André Anjos's avatar André Anjos 💬

[pnmio.cpp] Optimize for loop

parent 537c5f98
Pipeline #29375 passed with stage
in 18 minutes and 37 seconds
......@@ -462,7 +462,7 @@ int write_pgm_file(FILE *f, int *img_out,
/* Write the image data. */
for (i = 0; i < y_scaled_size; ++i) {
for (j = 0; j < x_scaled_size; j++) {
for (j = 0; j < x_scaled_size; ++j) {
if (is_ascii == 1) {
fprintf(f, "%d ", img_out[i*x_scaled_size+j]);
if (((i*x_scaled_size+j) % linevals) == (linevals-1)) {
......@@ -508,7 +508,7 @@ int write_ppm_file(FILE *f, int *img_out,
/* Write the image data. */
for (i = 0; i < y_scaled_size; ++i) {
for (j = 0; j < x_scaled_size; j++) {
for (j = 0; j < x_scaled_size; ++j) {
if (is_ascii == 1) {
fprintf(f, "%d %d %d ",
img_out[3*(i*x_scaled_size+j)+0],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment