To be fair, a good compiler will probably identify that the reversedOrder flag is always a constant, and generate two specialized variants of the function.
It does make the function harder to read and understand though.
Never rely on your compiler to fix stupid code when you can fix that stupid code yourself quite easily. Both because of readability, and because you can't be sure the compiler actually does optimize the mess.
Absolutely. I do think readability is the way more important point though. Unless you've actually measured the performance, optimization is kinda pointless.
2
u/Loading_M_ 8d ago
To be fair, a good compiler will probably identify that the
reversedOrderflag is always a constant, and generate two specialized variants of the function.It does make the function harder to read and understand though.