I have the following code:
char stats[109]; /* !LINE UNDER QUESTION! */
sprintf(stats,
"OBJECTS:\n%u/256\n" \
"BLOCKS:\n%u/" GP_ConstantExpand(Map_MaxLightmaps) "\n" \
"QUADS:\n%u/" GP_ConstantExpand(Map_MaxLightmaps) "\n" \
"LIGHTMAPS:\n%u/" GP_ConstantExpand(Map_MaxLightmaps) "\n" \
"CHECKPOINTS:\n%u/256\n" \
"HINTS:\n%u/256",
Map_This_Header.objects, Map_This_Header.blocks, Map_This_QuadCount,
lmapcount, Map_This_Header.checkpoints, Map_This_Header.hints);
Is it fine to statically allocate array of 109 chars (109 is enough for my text), or aligning the array to 128 bytes will increase performance?
I don’t care about file size and memory use, performance is important for me, my code must run at 60 FPS on old computers.
I guess this is too much related on the hardware on which the code will run. We can think for instance of two opposite arguments to answer this, assuming there will be other variables allocated on the stack around your array:
The second argument seems however less relevant, as it will only impact one variable among the many you can instantiate. In any case, you will need to benchmark your code if you want to be sure.