[ox/mc] Removes some unnecessary type conversions

This commit is contained in:
Gary Talent 2021-02-22 22:21:07 -06:00
parent 60714d3009
commit 034cb97a42

View File

@ -24,14 +24,14 @@ static constexpr auto Bits = sizeof(T) << 3;
*/ */
template<typename I> template<typename I>
[[nodiscard]] constexpr std::size_t highestBit(I val) noexcept { [[nodiscard]] constexpr std::size_t highestBit(I val) noexcept {
auto shiftStart = sizeof(I) * 8 - 1; int shiftStart = sizeof(I) * 8 - 1;
// find most significant non-sign indicator bit // find most significant non-sign indicator bit
std::size_t highestBit = 0; std::size_t highestBit = 0;
// start at one bit lower if signed // start at one bit lower if signed
if constexpr(ox::is_signed_v<I>) { if constexpr(ox::is_signed_v<I>) {
--shiftStart; --shiftStart;
} }
for (int i = shiftStart; i > -1; --i) { for (auto i = shiftStart; i > -1; --i) {
const auto bitValue = (val >> i) & 1; const auto bitValue = (val >> i) & 1;
if (bitValue) { if (bitValue) {
highestBit = i; highestBit = i;