For a project I am working on, I need to go through source code from a C++ program.
At several locations I am seeing something that I don't understand and I can't find anything about on the internet.
In several nested for loops, the counter var for the outer loop is set to itself. Is that to exit the loop, to skip one, anybody have any idea?
So it's the "n = n;" part :)
for (int n = 0; n < 12; n++) {
for (int m = 0; m < 99; m++) {
for (int p = 0; p < 10000; p++) {
if (p == 2300) {
n = n;
}
// code here
}
}
}
The n = n;
line of code does not do anything and the whole if (p == 2300) { n = n; }
part will probably be optimized away in a release build.
I suspect the reason the original author did this was so that they could put a breakpoint on the n = n;
line and catch it in the debugger when p is 2300. They probably submitted the change by mistake.
Modern IDEs will typically have a way of setting conditional breakpoints to break on such conditions but they can be slow and sometimes it is faster to recompile with a condition like this in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With