Neglecting memory consumption, does it matter using `int` or` char`?

Is there a difference in performance if I use intor char? My assumption would not be so, because both are transmitted on the parallel bus in the ALU. Therefore, depending on the architecture would be no difference between any base integers, int8_t, int16_tor int32_t, as they are under the system bit (32, 64, etc.). I'm not quite sure. It's true?

+3
source share
1 answer

If you are considering a single variable, then the integer code (native size) will always execute at least as fast, because masking or alignment should not be performed. However, if you are considering arrays (or, conversely, closely packed sets of variables), then smaller variables will fit into the cache line and be easily accessible to the kernel. The disadvantages of the cache add a significant delay, which leads to an increase in the efficiency of manipulating words of their own size in the kernel.

+1
source

All Articles