Messages in this thread |  | | Subject | Re: [PATCH 01/10] lib: introduce common method to convert hex digits | | From | Joe Perches <> | | Date | Fri, 30 Apr 2010 19:55:56 -0700 |
| |
On Fri, 2010-04-30 at 12:07 -0700, Andrew Morton wrote: > I had to fiddle with it: > - use tolower(), saving 3 bytes!
tolower could be done after the 0-9 case as well
int hex_to_bin(char ch) { if ((ch >= '0') && (ch <= '9')) return ch - '0'; ch = tolower(ch); if ((ch >= 'a') && (ch <= 'f')) return ch - 'a' + 10; return -1; }
|  |