JitArm64_RegCache: Simplify `std::find` using ranges and projections
This commit is contained in:
parent
8b1975ab18
commit
203923b267
|
@ -88,7 +88,7 @@ u32 Arm64RegCache::GetUnlockedRegisterCount() const
|
||||||
|
|
||||||
void Arm64RegCache::LockRegister(ARM64Reg host_reg)
|
void Arm64RegCache::LockRegister(ARM64Reg host_reg)
|
||||||
{
|
{
|
||||||
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
|
auto reg = std::ranges::find(m_host_registers, host_reg, &HostReg::GetReg);
|
||||||
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
|
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
|
||||||
"Don't try locking a register that isn't in the cache. Reg {}",
|
"Don't try locking a register that isn't in the cache. Reg {}",
|
||||||
static_cast<int>(host_reg));
|
static_cast<int>(host_reg));
|
||||||
|
@ -97,7 +97,7 @@ void Arm64RegCache::LockRegister(ARM64Reg host_reg)
|
||||||
|
|
||||||
void Arm64RegCache::UnlockRegister(ARM64Reg host_reg)
|
void Arm64RegCache::UnlockRegister(ARM64Reg host_reg)
|
||||||
{
|
{
|
||||||
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
|
auto reg = std::ranges::find(m_host_registers, host_reg, &HostReg::GetReg);
|
||||||
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
|
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
|
||||||
"Don't try unlocking a register that isn't in the cache. Reg {}",
|
"Don't try unlocking a register that isn't in the cache. Reg {}",
|
||||||
static_cast<int>(host_reg));
|
static_cast<int>(host_reg));
|
||||||
|
|
|
@ -150,8 +150,6 @@ public:
|
||||||
void Unlock() { m_locked = false; }
|
void Unlock() { m_locked = false; }
|
||||||
Arm64Gen::ARM64Reg GetReg() const { return m_reg; }
|
Arm64Gen::ARM64Reg GetReg() const { return m_reg; }
|
||||||
|
|
||||||
bool operator==(Arm64Gen::ARM64Reg reg) const { return reg == m_reg; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Arm64Gen::ARM64Reg m_reg = Arm64Gen::ARM64Reg::INVALID_REG;
|
Arm64Gen::ARM64Reg m_reg = Arm64Gen::ARM64Reg::INVALID_REG;
|
||||||
bool m_locked = false;
|
bool m_locked = false;
|
||||||
|
|
Loading…
Reference in New Issue