JitArm64_RegCache: Simplify std::find using ranges and projections

This commit is contained in:
mitaclaw 2024-10-05 16:08:35 -07:00
parent 8b1975ab18
commit 203923b267
2 changed files with 2 additions and 4 deletions

View File

@ -88,7 +88,7 @@ u32 Arm64RegCache::GetUnlockedRegisterCount() const
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(),
"Don't try locking a register that isn't in the cache. Reg {}",
static_cast<int>(host_reg));
@ -97,7 +97,7 @@ void Arm64RegCache::LockRegister(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(),
"Don't try unlocking a register that isn't in the cache. Reg {}",
static_cast<int>(host_reg));

View File

@ -150,8 +150,6 @@ public:
void Unlock() { m_locked = false; }
Arm64Gen::ARM64Reg GetReg() const { return m_reg; }
bool operator==(Arm64Gen::ARM64Reg reg) const { return reg == m_reg; }
private:
Arm64Gen::ARM64Reg m_reg = Arm64Gen::ARM64Reg::INVALID_REG;
bool m_locked = false;