Hacker News new | ask | show | jobs
by cixin 3446 days ago
Wow awesome! It's partly these little optimizations that keeps C/C++ going.

I've never considered that const might have a performance benefit (and mostly just use it as a compile time check). But will consider it in the future.

Would be interesting to see performance benchmarks for the changes made here, as well as applying const in general.

1 comments

Ignoring the VC++ compiler bug/quirk, the benefits for adding const tend to be small and hard to measure. How do you measure the possible reduction in private pages? How do you measure the productivity gains from slightly fewer corrupted globals.

Usually you don't. You just tag your const globals as such and then get on with your day. Once you develop the habit the cost is zero so measuring the benefits isn't necessary.