From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752396AbcF3T0T (ORCPT ); Thu, 30 Jun 2016 15:26:19 -0400 Received: from smtprelay0132.hostedemail.com ([216.40.44.132]:37263 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752318AbcF3T0Q (ORCPT ); Thu, 30 Jun 2016 15:26:16 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2898:3138:3139:3140:3141:3142:3151:3354:3622:3865:3867:3868:3870:3871:3872:3873:4321:5007:6742:7808:7903:10004:10400:10848:11026:11232:11658:11783:11914:12048:12296:12517:12519:12555:12740:13069:13311:13357:13439:13894:14659:14721:21080:21324:21433:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: birds36_705ac4fc2bf53 X-Filterd-Recvd-Size: 3160 Message-ID: <1467314771.24287.160.camel@perches.com> Subject: Re: [PATCH 1/2] lib: hexdump: use a look-up table to do hex_to_bin From: Joe Perches To: Andy Shevchenko , Michal Nazarewicz , zengzhaoxiu@163.com, linux-kernel@vger.kernel.org Cc: Zhaoxiu Zeng , Andrew Morton , Hidehiro Kawai , Borislav Petkov , Michal Hocko , Rasmus Villemoes , Nicolas Iooss , "Steven Rostedt (Red Hat)" , Gustavo Padovan , Geert Uytterhoeven , Horacio Mijail Anton Quiles Date: Thu, 30 Jun 2016 12:26:11 -0700 In-Reply-To: <1467226354.30123.336.camel@linux.intel.com> References: <1467216957-58885-1-git-send-email-zengzhaoxiu@163.com> <1467226354.30123.336.camel@linux.intel.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2016-06-29 at 21:52 +0300, Andy Shevchenko wrote: > On Wed, 2016-06-29 at 20:31 +0200, Michal Nazarewicz wrote: [] > > tolower macro maps to __tolower function which calls isupper to > > to determine if character is an upper case letter before converting > > it to lower case.  This preservers non-letters unchanged which is > > what you want in usual case. > > > > However, hex_to_bin does not care about non-letter characters so > > such conversion can be performed as long as (i) upper case letters > > become lower case, (ii) lower case letters are unchanged and (iii) > > non-letters stay non-letters. > > > > This is exactly what _tolower function does and using it makes it > > possible to avoid _ctype table lookup performed by the isupper > > table. > > > > Furthermore, since _tolower conversion is done unconditionally, this > > also eliminates a single branch. > This change I agree with since _tolower() is specific for lib internal > usage in the kernel. Perhaps _tolower should be used a bit more in lib ---  lib/string.c | 8 ++++----  1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/string.c b/lib/string.c index ed83562..b0e72fd 100644 --- a/lib/string.c +++ b/lib/string.c @@ -53,8 +53,8 @@ int strncasecmp(const char *s1, const char *s2, size_t len)   break;   if (c1 == c2)   continue; - c1 = tolower(c1); - c2 = tolower(c2); + c1 = _tolower(c1); + c2 = _tolower(c2);   if (c1 != c2)   break;   } while (--len); @@ -69,8 +69,8 @@ int strcasecmp(const char *s1, const char *s2)   int c1, c2;     do { - c1 = tolower(*s1++); - c2 = tolower(*s2++); + c1 = _tolower(*s1++); + c2 = _tolower(*s2++);   } while (c1 == c2 && c1 != 0);   return c1 - c2;  }