From: Jean Delvare <jdelvare@suse.de>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Michal Marek <mmarek@suse.cz>
Subject: Re: [PATCH 2/3] kconfig: avoid multiple calls to strlen
Date: Tue, 16 Jul 2013 16:21:41 +0200 [thread overview]
Message-ID: <1373984501.4513.8.camel@chaos.site> (raw)
In-Reply-To: <1373738905-23396-3-git-send-email-yann.morin.1998@free.fr>
Le Saturday 13 July 2013 à 20:08 +0200, Yann E. MORIN a écrit :
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> Calls to strlen are costly, so avoid calling strln as much as we can.
Typo: strln -> strlen.
> Reported-by: Jean Delvare <jdelvare@suse.de>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Jean Delvare <jdelvare@suse.de>
> ---
> scripts/kconfig/symbol.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index d550300..020a0ac 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -967,7 +967,7 @@ static int sym_rel_comp( const void *sym1, const void *sym2 )
> {
> struct sym_match *s1 = *(struct sym_match **)sym1;
> struct sym_match *s2 = *(struct sym_match **)sym2;
> - int l1, l2;
> + int exact1, exact2;
>
> /* Exact match:
> * - if matched length on symbol s1 is the length of that symbol,
> @@ -978,11 +978,11 @@ static int sym_rel_comp( const void *sym1, const void *sym2 )
> * exactly; if this is the case, we can't decide which comes first,
> * and we fallback to sorting alphabetically.
> */
> - l1 = s1->eo - s1->so;
> - l2 = s2->eo - s2->so;
> - if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name))
> + exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
> + exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
> + if (exact1 && !exact2)
> return -1;
> - if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name))
> + if (!exact1 && exact2)
> return 1;
>
> /* As a fallback, sort symbols alphabetically */
Looks good and tested OK.
Reviewed-by: Jean Delvare <jdelvare@suse.de>
--
Jean Delvare
Suse L3
next prev parent reply other threads:[~2013-07-16 14:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-13 18:08 [PATCH 0/3] Misc cleanups in kconfig for symbol-search Yann E. MORIN
2013-07-13 18:08 ` [PATCH 1/3] Documentation/kconfig: more concise and straightforward search explanation Yann E. MORIN
2013-07-13 18:14 ` Yann E. MORIN
2013-07-16 14:14 ` Jean Delvare
2013-07-13 18:08 ` [PATCH 2/3] kconfig: avoid multiple calls to strlen Yann E. MORIN
2013-07-16 14:21 ` Jean Delvare [this message]
2013-07-13 18:08 ` [PATCH 3/3] kconfig: cleanup symbol-search code Yann E. MORIN
2013-07-16 14:33 ` Jean Delvare
2013-07-16 14:42 ` Yann E. MORIN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373984501.4513.8.camel@chaos.site \
--to=jdelvare@suse.de \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=yann.morin.1998@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox