News for hackers. Stuff that matters.
Re:Dangerous Embedded C Coding Standard Rules (2011) by wtracy on Monday December 30, 2013 @12:45PM (#6985722)
Another reason to pay attention to #2: Most CPUs perform simple arithmetic operations fastest on their native word size. On a 32-bit machine, addition and subtraction on 8-bit variables is probably slower than on 32-bit variables. (Often the hardware will transparently cast to 32 bits, perform the operation, then cast back to 8 bits.)

I'm not an authority on this topic, so I don't want you to take away the message "always use the machine word size". What I do want you to take away is that there are many cases where an "obvious" optimization is counterproductive in practice. Always start with simple, working code, and never optimize without benchmarking.

Re:Dangerous Embedded C Coding Standard Rules (2011) by alecrn on Monday December 30, 2013 @04:16PM (#6987012)
For this case, the "fast" int types are provided, eg. uint_fast8_t is the fastest unsigned integer which can hold at least 8 bits; uint8_t is required to have exactly 8 bits.

http://pubs.opengroup.org/onlinepubs/7999959899/basedefs/std...