Messages in this thread | | | Date | Tue, 19 Feb 2002 16:52:30 +0100 | From | Martin Dalecki <> | Subject | Re: [PATCH] hex <-> int conversion routines. |
| |
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/
| |