Add some performance hints to conditionals.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-29 14:56:26 +00:00
parent 412a44fafd
commit 8e4030a5aa
2 changed files with 5 additions and 5 deletions

View File

@ -162,14 +162,14 @@ namespace EightBit {
}
uint8_t AM_AbsoluteX() {
if (Address_AbsoluteX())
if (UNLIKELY(Address_AbsoluteX()))
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();
}
uint8_t AM_AbsoluteY() {
if (Address_AbsoluteY())
if (UNLIKELY(Address_AbsoluteY()))
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();
@ -191,7 +191,7 @@ namespace EightBit {
}
uint8_t AM_IndirectIndexedY() {
if (Address_IndirectIndexedY())
if (UNLIKELY(Address_IndirectIndexedY()))
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();

View File

@ -336,7 +336,7 @@ int EightBit::MOS6502::execute(uint8_t cell) {
__assume(0);
}
if (cycles() == 0)
if (UNLIKELY(cycles() == 0))
throw std::logic_error("Unhandled opcode");
return cycles();
@ -480,7 +480,7 @@ void EightBit::MOS6502::ADC_d(uint8_t data) {
void EightBit::MOS6502::Branch(int8_t displacement) {
const auto page = PC().high;
PC().word += displacement;
if (PC().high != page)
if (UNLIKELY(PC().high != page))
addCycle();
addCycle();
}