Performance when using uint_fast8_t?

So, after a lot of engine research, I created the 2nd iphone framework. As you know, the world of engine architecture is vast, so I try to apply the best practices as much as possible.

I used:

uint_fast8_t mId; 

If I look at the definition of uint_fast8_t, I find:

 /* 7.18.1.3 Fastest-width integer types */ ... typedef uint8_t uint_fast8_t; 

And I use these types in all my code. My question is, is there a performance advantage for using these types? And what exactly is going on behind the scenes? Besides the obvious fact that this is the correct data type (unsigned 8-bit integer) for the data, is it worth it to transfer to all my code?

Is this really an unnecessary optimization that the compiler is likely to take care of anyway?

Thanks.

Edit: No replies / replies, so I give you generosity!

+6
types iphone game-engine
source share
3 answers

“fast” integer types are defined as the fastest integer type, available at least with the number of bits (in this case, 8).

If your platform defines uint_fast8_t as uint8_t, then there will be no difference in speed.

The reason is that there may be architectures that are slower if you do not use their native word length. For example. I could find one link where for alpha processors uint_fast_8_t was defined as "unsigned int".

+20
source share

. uint_fast8_t is the fastest integer guaranteed to be at least 8 bits wide. Depending on your platform, it can be 8 or 16 or 32 bits wide.

It does not care about the compiler, it really speeds up the execution of your program

Here is some resource I found. You may have already seen them http://embeddedgurus.com/stack-overflow/2008/06/efficient-c-tips-1-choosing-the-correct-integer-size/

http://www.mail-archive.com/ avr-gcc-list@nongnu.org /msg03149.html

+3
source share

mingw64 says so:

 /* 7.18.1.3 Fastest minimum-width integer types * Not actually guaranteed to be fastest for all purposes <--------------------- * Here we use the exact-width types for 8 and 16-bit ints. */ typedef signed char int_fast8_t; typedef unsigned char uint_fast8_t; typedef short int_fast16_t; typedef unsigned short uint_fast16_t; typedef int int_fast32_t; typedef unsigned int uint_fast32_t; __MINGW_EXTENSION typedef long long int_fast64_t; __MINGW_EXTENSION typedef unsigned long long uint_fast64_t; 

so I believe it is still recommended to use int int size except for large arrays

-one
source share

All Articles