The performance improvement was verified with following code: ``` #include <stdio.h> #include <stdlib.h> #include <time.h> /* for(y) for(x) 9.05 */ /* for(x) for(y) 39.69 */ int main() { long width, height; long has_alpha; long x, y; unsigned int * src;
width= 5000; height = 999999; src = (unsigned int*)malloc(width*height*sizeof(unsigned int)); has_alpha = 0; clock_t t;
t = clock();
for (x=0; x<width && !has_alpha; x++) for (y=0; y<height && !has_alpha; y++) { //printf(" %i", *src); if ((src[y*width + x] & 0xff000000) != 0) has_alpha = 1; } t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
printf("fun() took %f seconds to execute \n", time_taken);
return 0; } ```
It could be verified with Online compilers: https://godbolt.org/ https://www.programiz.com/c-programming/online-compiler/#google_vignette