5 ms·
I remember changing a _constant_ int into a volatile global variable, and my code became 4 times faster. It was on Ubuntu 16.04. I might actually find code and
by SomeoneFromCA 6y ago
I remember changing a _constant_ int into a volatile global variable, and my code became 4 times faster. It was on Ubuntu 16.04. I might actually find code and post here later.
- sfblah 6y agoI worked on some code once for an app that would crash if you added a comment in a specific place. We removed the comment and then added a comment asking developers not to re-add the comment.
- IAmLiterallyAB 6y agoWas it a language where the comment would be compiled out ahead of time? Or still present at runtime like JS
- quietbritishjim 6y agoI was thinking the same thing. It would be very odd if it had an effect on C or C++ (even more than the effect in the original article) because comments are removed even before preprocessing. They do affect the __LINE__ macro though, so it is vaguely conceivable for it to have an effect on program behaviour.
- a_t48 6y agoIt didn't happen to end with a '\' did it? :)
- IvyMike 6y agoOr, better yet, '??/', the trigraph for '\'?
- gaogao 6y agoOh nice, we had a load bearing comment too at work.
- staycoolboy 6y agoInteresting. Were you writing a kernel driver? I've only ever used 'volatile' in embedded code where an ISR is touching a variable outside the scope to prevent the compiler from optimizing the code away. What were using 'volatile' for?
- SomeoneFromCA 6y agoNo it was some random debugging of Leet Code style excercise, some useless math computation. I just was throwing every possible change, till one worked. I knew that code had to be fast than it was, because with PGO it was very fast.