News for hackers. Stuff that matters.
Re:When static makes your C code 10 times faster by painchoc on Sunday July 04, 2021 @11:13AM (#27730256)
It is mostly about the fact that if the variable is not static, then it's non-local to the translation unit and can be modified from everywhere else. So its value needs to be loaded and a plain and slow division is applied.

Having it local or const makes the compiler able to inline it and do a simple bitwise and with a constant.

So yes, make your variables static const by default (if you really need global).

There are no comments on this comment yet.