Re: [PATCH] hex <-> int conversion routines.

From: Linus Torvalds (torvalds@transmeta.com)
Date: Tue Feb 19 2002 - 13:02:46 EST


On Tue, 19 Feb 2002, Jakob Kemi wrote:
>
> I also added three other hex-functions that can replace a lot of duplicated code.
>
> int hexint_nibble (char x); // hex digit to int.
> int hexint_byte (const char *src); // hex digit-pair to int.
> char inthex_nibble (int x); // int to hex digit.
> void inthex_byte (int x, char* dest); // int to hex digit pair.

Is there any reason to do all of this?

I suspect 99% of all users can (and probably should) be replaced with
"sscanf()" instead. Which does a lot more, of course, and is not the
fastest thing out there due to that, but anybody who does hex->int
conversion inside some critical loop is just crazy.

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 23 2002 - 21:00:20 EST