From 108f66632ec7697f0372c3c6ef0578b4c7fec991 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Sat, 6 Jan 2018 17:13:02 +0000 Subject: [PATCH] Performance: watch out for unnecessary virtualised methods. Signed-off-by: Adrian Conlon --- inc/IntelProcessor.h | 4 ++-- inc/Processor.h | 10 ++++++++-- src/Processor.cpp | 9 --------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/inc/IntelProcessor.h b/inc/IntelProcessor.h index 5b9be6e..89494ec 100644 --- a/inc/IntelProcessor.h +++ b/inc/IntelProcessor.h @@ -125,8 +125,8 @@ namespace EightBit { MEMPTR().word++; } - virtual void getWordViaMemptr(register16_t& value); - virtual void setWordViaMemptr(register16_t value); + void getWordViaMemptr(register16_t& value); + void setWordViaMemptr(register16_t value); // diff --git a/inc/Processor.h b/inc/Processor.h index 198e79d..cc6859f 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -106,8 +106,14 @@ namespace EightBit { void halt() { --PC().word; lower(HALT()); } void proceed() { ++PC().word; raise(HALT()); } - virtual uint8_t fetchByte(); - virtual void fetchWord(register16_t& output); + uint8_t fetchByte() { + return getByte(PC().word++); + } + + void fetchWord(register16_t& output) { + output.low = fetchByte(); + output.high = fetchByte(); + } void fetchWord() { fetchWord(MEMPTR()); diff --git a/src/Processor.cpp b/src/Processor.cpp index 8dc25d4..9d70d85 100644 --- a/src/Processor.cpp +++ b/src/Processor.cpp @@ -27,12 +27,3 @@ int EightBit::Processor::singleStep() { reset(); return step(); } - -uint8_t EightBit::Processor::fetchByte() { - return getByte(PC().word++); -} - -void EightBit::Processor::fetchWord(register16_t& output) { - output.low = fetchByte(); - output.high = fetchByte(); -}