Codechange: replace ROR/ROL with std::rotr/rotl
This commit is contained in:
@@ -288,38 +288,6 @@ inline bool HasAtMostOneBit(T value)
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ROtate \a x Left by \a n
|
||||
*
|
||||
* @note Assumes a byte has 8 bits
|
||||
* @param x The value which we want to rotate
|
||||
* @param n The number how many we want to rotate
|
||||
* @pre n < sizeof(T) * 8
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template <typename T>
|
||||
inline T ROL(const T x, const uint8_t n)
|
||||
{
|
||||
if (n == 0) return x;
|
||||
return (T)(x << n | x >> (sizeof(x) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* ROtate \a x Right by \a n
|
||||
*
|
||||
* @note Assumes a byte has 8 bits
|
||||
* @param x The value which we want to rotate
|
||||
* @param n The number how many we want to rotate
|
||||
* @pre n < sizeof(T) * 8
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template <typename T>
|
||||
inline T ROR(const T x, const uint8_t n)
|
||||
{
|
||||
if (n == 0) return x;
|
||||
return (T)(x >> n | x << (sizeof(x) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterable ensemble of each set bit in a value.
|
||||
* @tparam Tbitpos Type of the position variable.
|
||||
|
@@ -33,8 +33,8 @@ uint32_t Randomizer::Next()
|
||||
const uint32_t s = this->state[0];
|
||||
const uint32_t t = this->state[1];
|
||||
|
||||
this->state[0] = s + ROR(t ^ 0x1234567F, 7) + 1;
|
||||
return this->state[1] = ROR(s, 3) - 1;
|
||||
this->state[0] = s + std::rotr(t ^ 0x1234567F, 7) + 1;
|
||||
return this->state[1] = std::rotr(s, 3) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user