[alsa-devel] [PATCH] Avoid useless loop
From: xingchao keroid1@gmail.com
Only drop to the for loop to bind DAI when the work is not finished.
Signed-off-by: xingchao keroid1@gmail.com --- sound/soc/soc-core.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4dda589..0380a26 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1810,8 +1810,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) }
/* bind DAIs */ - for (i = 0; i < card->num_links; i++) - soc_bind_dai_link(card, i); + if (card->num_rtds != card->num_links) { + for (i = 0; i < card->num_links; i++) + soc_bind_dai_link(card, i); + }
/* bind completed ? */ if (card->num_rtd != card->num_links) {
On Sun, Apr 10, 2011 at 07:19:20PM -0400, keroid1@gmail.com wrote:
/* bind DAIs */
- for (i = 0; i < card->num_links; i++)
soc_bind_dai_link(card, i);
if (card->num_rtds != card->num_links) {
for (i = 0; i < card->num_links; i++)
soc_bind_dai_link(card, i);
}
/* bind completed ? */ if (card->num_rtd != card->num_links) {
It seems odd to have two if statements testing the same condition in immediate succession, though we do need the second check after the flor loop to match the final bind. I'm not sure this is doing much except adding a little complexity - it's not like this is a hot path.
participants (2)
-
keroid1@gmail.com
-
Mark Brown