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

Linus Torvalds (torvalds@transmeta.com)
Tue, 19 Feb 2002 10:02:46 -0800 (PST)


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/