Remove rarely true check in char_traits::move#2083
Remove rarely true check in char_traits::move#2083StephanTLavavej merged 1 commit intomicrosoft:mainfrom
Conversation
This code is only executed at compile time, but I agree that it's unnecessary. |
|
On second thought, since this is a compile time constant, I wonder if this is a good idea. |
My intuition is that "self-assignment" at compile time is as rare as "self-assignment" at runtime and that the guard won't trigger often enough to offset the cost of evaluation. I don't think any of our supported compilers currently implements a branch predictor for |
|
True. Maybe when our compiler is better. |
While it is faster to just leave when the source and destination are the same, most programmers would not make that mistake, and if they did, it would be a rarity and a reflection of something going wrong in their code in the first place. There is no reason to do this check if speed and code size are of utmost importance.
|
Alright I squashed everything and rebased, so this should be good to go! |
It's not an issue given how small this change is, but for future reference please avoid force-pushing the branch since it interferes with incremental code review. (Merging |
|
Alright, thank you! |
|
Thanks for removing this unnecessary code! 😺 🧹 🎉 |
While it is faster to just leave when the source and destination are the same, most programmers would not make that mistake, and if they did, it would be a rarity and a reflection of something going wrong in their code in the first place.
There is no reason to do this check if speed and code size are of utmost importance.