2 ms·
> None of it really shocking or new, unless you have been > writing to one compiler implementation instead of to > the standard. I think you should focus more
by brucedawson 10y ago
> None of it really shocking or new, unless you have been
> writing to one compiler implementation instead of to
> the standard.
I think you should focus more on giving concrete examples instead of making snide comments.
And, I'm not going to watch an eighty minute video in order to find out what you are talking about. Specific examples would be appreciated.
I agree that tagging globals as const can help the optimizer. If that is what you were talking about then I have no disagreement. However I have seen many people who expect speed wins when they tag member functions as const, or local variables as const. In those cases it is rare for 'const' to improve code-gen.
- sqeaky 10y agoI was not attempting to be snide or rude. You are free to take the very concrete example I provided or not. You cannot say I didn't provide any. The instant where the const keyword removes 95+% of the generated machine code is just after 28:00, but you should watch from at least a few minutes before that to establish context. That wasn't a global he put it on, but it wasn't a member variable either. I recommend watching the whole talk, because the whole thing is pertinent to what optimizing can and cannot do. Because the speaker wants to get modern software onto an old machine he works around tight constraints while getting all of C++17. If you choose not to ignore something that you have expressed an interest in and is pertinent then you are doing something far worse than being rude and you are doing it to yourself. Go benchmark you code, I have benchmarked mine. Putting const everywhere applicable helps even back in the pre-C++11 days. I state again not trusting and working with your optimizing compiler is simply an old an outmoded way of thinking.