Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Byte Endian Portability and Efficiency . . . . . . . . . . (was Re: Portability of Misaligned Data Access)



On Fri, 28 Jul 2006 11:48:21 +0100 Ian Wells <ijw@example.com> wrote:

> 
> uint16_t read_le_u16(char *x) {
>    return (uint16_t)x[0]+(((uint16_t)x[1]) <<8);
> }
> 
> In the nature of these things, this looks obviously inefficient and
> slow, and therefore it's almost guaranteed not to be the thing that
> takes up the majority of the time (rule #3).

Yup. 

Even on the creaky buggy compilers I use for the crummy 8-bit micros 
I code for, they generate efficient code for shifts by multiples of 8. 



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links