Replace BitUtils with C++20: RotateLeft/RotateRight

Now that we've flipped the C++20 switch, let's start making use of
the nice new <bit> header.

I'm planning on handling this move away from BitUtils.h incrementally
in a series of PRs. There may be a few functions remaining in
BitUtils.h by the end that C++20 doesn't have any equivalents for.
This commit is contained in:
JosJuice
2022-08-05 15:39:00 +02:00
parent 48ce5318e1
commit 454537d53e
11 changed files with 63 additions and 141 deletions

View File

@ -4,7 +4,9 @@
#include "Common/Hash.h"
#include <algorithm>
#include <bit>
#include <cstring>
#include <zlib.h>
#include "Common/BitUtils.h"
@ -60,15 +62,15 @@ static u64 getblock(const u64* p, int i)
static void bmix64(u64& h1, u64& h2, u64& k1, u64& k2, u64& c1, u64& c2)
{
k1 *= c1;
k1 = Common::RotateLeft(k1, 23);
k1 = std::rotl(k1, 23);
k1 *= c2;
h1 ^= k1;
h1 += h2;
h2 = Common::RotateLeft(h2, 41);
h2 = std::rotl(h2, 41);
k2 *= c2;
k2 = Common::RotateLeft(k2, 23);
k2 = std::rotl(k2, 23);
k2 *= c1;
h2 ^= k2;
h2 += h1;