From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753982AbbFOFHn (ORCPT ); Mon, 15 Jun 2015 01:07:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:4084 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbbFOFHd (ORCPT ); Mon, 15 Jun 2015 01:07:33 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,616,1427785200"; d="scan'208";a="710988948" Date: Mon, 15 Jun 2015 10:38:57 +0530 From: Vinod Koul To: Rasmus Villemoes Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, yang.a.fang@intel.com Subject: Re: [PATCH] ASoC: Intel: mrfld: simplify sst_fill_widget_module_info Message-ID: <20150615050856.GQ28601@localhost> References: <1433405633-18656-1-git-send-email-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433405633-18656-1-git-send-email-linux@rasmusvillemoes.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2015 at 10:13:53AM +0200, Rasmus Villemoes wrote: > Some tiny improvements, cutting 180 bytes off the generated code. > > - use strchr() for single-character needle > > - compute index using pointer subtraction instead of two strlen() > calls > > - factor out the common check for whether the initial part of > kctl->id.name (before the space) is identical to w->name. Acked-by: Vinod Koul -- ~Vinod > > Signed-off-by: Rasmus Villemoes > --- > sound/soc/intel/atom/sst-atom-controls.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c > index 90aa5c0476f3..16670feeee6a 100644 > --- a/sound/soc/intel/atom/sst-atom-controls.c > +++ b/sound/soc/intel/atom/sst-atom-controls.c > @@ -1280,36 +1280,32 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, > down_read(&card->controls_rwsem); > > list_for_each_entry(kctl, &card->controls, list) { > - idx = strstr(kctl->id.name, " "); > + idx = strchr(kctl->id.name, ' '); > if (idx == NULL) > continue; > - index = strlen(kctl->id.name) - strlen(idx); > + index = idx - (char*)kctl->id.name; > + if (strncmp(kctl->id.name, w->name, index)) > + continue; > > - if (strstr(kctl->id.name, "Volume") && > - !strncmp(kctl->id.name, w->name, index)) > + if (strstr(kctl->id.name, "Volume")) > ret = sst_fill_module_list(kctl, w, SST_MODULE_GAIN); > > - else if (strstr(kctl->id.name, "params") && > - !strncmp(kctl->id.name, w->name, index)) > + else if (strstr(kctl->id.name, "params")) > ret = sst_fill_module_list(kctl, w, SST_MODULE_ALGO); > > else if (strstr(kctl->id.name, "Switch") && > - !strncmp(kctl->id.name, w->name, index) && > strstr(kctl->id.name, "Gain")) { > struct sst_gain_mixer_control *mc = > (void *)kctl->private_value; > > mc->w = w; > > - } else if (strstr(kctl->id.name, "interleaver") && > - !strncmp(kctl->id.name, w->name, index)) { > + } else if (strstr(kctl->id.name, "interleaver")) { > struct sst_enum *e = (void *)kctl->private_value; > > e->w = w; > > - } else if (strstr(kctl->id.name, "deinterleaver") && > - !strncmp(kctl->id.name, w->name, index)) { > - > + } else if (strstr(kctl->id.name, "deinterleaver")) { > struct sst_enum *e = (void *)kctl->private_value; > > e->w = w; > -- > 2.1.3 > --