-
-
Couldn't load subscription status.
- Fork 496
Refactor CVector/2D/4D to use constexpr + noexcept everywhere #1478
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
Conversation
|
OMG IT WORKS ON THE FIRST TRY jeez m8 thats gr8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've left a couple style comments, a comment comment, and a suggestion to keep one potential optimisation.
|
I feel like that "potential optimization" is quite unnecessary, as, by default MSVC uses SSE2, which will probably dump all the 4 floats into a m128 reg, and divide them. Which wont be much slower than just doing this optimization trick(which we shoudnt, as the compiler will optimize it, especially if we enable fast-math(which will pretty much guarantee us that the compiler will use SSE2 with this trick we've used: #pragma fast-math push
#pragma fast-math on
// code
#pragma fast-math pop |
Why is constexpr needed there? The main purpose of constexpr is to compute the result in compile time. That can only happen if the compiler knows about the values used in the method at compile-time, otherwise, it will just inline it at best and won't do any good optimizations. |
|
As stated somewhere, I need this for the CGraphics refactor thingy |
Basically this PR makes the above mentioned classes use constexpr, and noexcept everywhere they can.
All functions other than the constructors were probably inlined before anyways, but declaring the constructors as
constexprallows me(or someone else), to declare constexpr variables with vectors.Its kinda useful, just gives me that constifying feel.
These edits are cherry-picked from #1467