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

From: Martin Dalecki (dalecki@evision-ventures.com)
Date: Tue Feb 19 2002 - 10:52:30 EST


Jakob Kemi wrote:
> Hi,
>
> When grepping through the kernel I noticed that there exists at least 27
> (probably more with non-obvious names) different implementations of hex to
> int conversion functions. 2/3 of them in arch and the rest in drivers and fs.
> All implementations were variations of this function:

Fine...

> +static __inline__ int _hexint_byte(const char *src)
> +{

...

> +}

Not worth inlining. char conversion are seldomly time critical.

> +static __inline__ int hexint_nibble(char x)

Same applies here.

> +static __inline__ char inthex_nibble(int x)
> +{
> + const char* digits = "0123456789abcdef";
> +
> + return digits[x & 0x0f];
> +}

perhaps better do static const char *digits.

> +static __inline__ void inthex_byte(int x, char* dest)
> +{
> + const char* digits = "0123456789abcdef";
> +
> + dest[0] = digits[(x & 0xf0) >> 4];
> + dest[1] = digits[x & 0x0f];
> +}

perhaps better do static const char *digits.

Regards.

-
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