From: Yann E. MORIN Date: Sat, 13 Jul 2013 13:09:43 +0000 (+0200) Subject: kconfig: avoid multiple calls to strlen X-Git-Tag: 1.9.9~13 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=4c9a4d5505c463aa2a35b6a199910fd92e387566;p=carl9170fw.git kconfig: avoid multiple calls to strlen Calls to strlen are costly, so avoid calling strln as much as we can. Reported-by: Jean Delvare Signed-off-by: "Yann E. MORIN" Cc: Jean Delvare Reviewed-by: Jean Delvare Signed-off-by: Christian Lamparter --- diff --git a/config/symbol.c b/config/symbol.c index d550300..020a0ac 100644 --- a/config/symbol.c +++ b/config/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 */