[alsa-devel] [PATCH 11/39] firewire-lib: Add support for channel mapping

Takashi Sakamoto o-takashi at sakamocchi.jp
Tue Mar 11 17:03:13 CET 2014

(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.


Takashi Sakamoto
o-takashi at sakamocchi.jp

More information about the Alsa-devel mailing list