News for hackers. Stuff that matters.
Re:When static makes your C code 10 times faster by kevin_b_er on Sunday July 04, 2021 @11:26AM (#27730363)
I agree. Static alone was the incorrect choice. If the global were being modified elsewhere in the file then this optimization would also not be possible.

The core optimization is modulus % constant (and a power-of-2 as well). The static just enabled the optimizer to do better heavy lifting to get there. A const would've made the intent clear to the human reader and the compiler.

static const would've been best.

There are no comments on this comment yet.