yuzu-emu
/
yuzu
Archived
1
0
Fork 0

video_core/macro_interpreter: Simplify GetRegister()

Given we already ensure nothing can set the zeroth register in
SetRegister(), we don't need to check if the index is zero and special
case it. We can just access the register normally, since it's already
going to be zero.

We can also replace the assertion with .at() to perform the equivalent
behavior inline as part of the API.
This commit is contained in:
Lioncash 2019-04-05 22:51:22 -04:00
parent 66be5150d6
commit 1efdb4897e
1 changed files with 6 additions and 11 deletions

View File

@ -228,22 +228,17 @@ u32 MacroInterpreter::FetchParameter() {
} }
u32 MacroInterpreter::GetRegister(u32 register_id) const { u32 MacroInterpreter::GetRegister(u32 register_id) const {
// Register 0 is supposed to always return 0. return registers.at(register_id);
if (register_id == 0)
return 0;
ASSERT(register_id < registers.size());
return registers[register_id];
} }
void MacroInterpreter::SetRegister(u32 register_id, u32 value) { void MacroInterpreter::SetRegister(u32 register_id, u32 value) {
// Register 0 is supposed to always return 0. NOP is implemented as a store to the zero // Register 0 is hardwired as the zero register.
// register. // Ensure no writes to it actually occur.
if (register_id == 0) if (register_id == 0) {
return; return;
}
ASSERT(register_id < registers.size()); registers.at(register_id) = value;
registers[register_id] = value;
} }
void MacroInterpreter::SetMethodAddress(u32 address) { void MacroInterpreter::SetMethodAddress(u32 address) {