Re: [PATCH 1/2] lib: hexdump: use a look-up table to do hex_to_bin

From: Zhaoxiu Zeng
Date: Thu Jun 30 2016 - 10:23:34 EST


On 2016/6/30 2:31, Michal Nazarewicz wrote:
> On Thu, Jun 30 2016, zengzhaoxiu wrote:
.......
>> So this replaces table lookup in tolower with an explicit table lookup
>> here while also removing some branches.
>>
>> Is that an improvement? Hard to say. _ctype table is used by all the
>> other isfoo macros so thereâs a chance itâs already in cache the first
>> time hex_to_bin is called. Having to read the data into cache may
>> overwhelm advantages of lack of branches.

In the 2nd patch, I use the inlined hex_to_bin to replace the local conversion
in _parse_integer which used by all kstrto... functions, so the heat of h2b_lut
may not be less than _ctype table.

Additionallyïin the vast majority of casesïonly these bytes (0x00, 0x30~0x39,
0x41~0x46, 0x61~0x66) will be used.