-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove rarely true check in char_traits::move #2083
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.