We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi Experts,
unsigned int var1_32; unsigned int var2_32; unsigned short int var1_16; unsigned short int var2_16; unsigned char var1_8; unsigned char var2_8;
In the above declarations which is faster,
if(var1_32 == var2_32) { }
or
if(var1_16 == var2_16) { }
if(var1_8 == var2_8) { }
Dave's comments are spot on here. In general, the compiler will do a very good job with what you give it. But some thought into the most efficient/appropriate/suitable data types will give it a lot of help.
One other reason which occurs to me for using "small" containers is the possibility of getting much more value out of SIMD instructions. The NEON architecture (and to a lesser extend the v6 SIMD extensions) are capable of handling a number of individual data items packed into wide vector registers. The smaller the items are, the more of them you can fit into a vector. This can pay huge dividends if used correctly.
Chris