On Mon, Apr 07, 2008 at 08:45:57PM -0600, Jordan Crouse wrote:
- return "0123456789abcdef"[b & 15];
Neat. :)
Hmm - now that you mention it - thats 16 bytes of const data. This might be more efficient (but not as cute):
return (b < 10) ? '0' + b : 'a' + (b - 10);
That probably comes close to 16 bytes of code though.
and 2 add 2 cmp 2 jle 2 add 2
10.. (IIRC the jump is just 2 byte when this short.)
Sure, the index and and make for 4 bytes too, but do the 10 bytes matter? :)
//Peter