Skip to content

Comment on When static makes your C code 10 times fasterparent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.