(Mar 11 2014 17:23), Clemens Ladisch wrote:
In code like this:
for (... s->channels ...) buffer[i] = ...;
it is, as far as the compiler knows, possible that &buffer[i] and &s->channels actually point to the same variable, so s->channels must be reloaded in every loop iteration. A local variable avoids that.
(Whether this optimization is worth it is another question ...)
As long as I test with simple codes and gcc, this optimization reduce one opcode in a loop. Codes with your way compares address content to a register, but codes with my way once push address content to another register and compare the two registers.
The read/write functions are called the most freqently, so shorter codes are preferable. I realize I should keep it what you wrote. Thanks for your indication.
Thanks
Takashi Sakamoto o-takashi@sakamocchi.jp