From c65d8585d45b24029e9354c4a53148cd3ce7a416 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Sat, 19 Oct 2019 18:41:10 +0200 Subject: [PATCH] Fix performance regression. Avoid array copy. --- memoryManager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memoryManager.go b/memoryManager.go index 56360f3..32f02bd 100644 --- a/memoryManager.go +++ b/memoryManager.go @@ -33,7 +33,7 @@ const ( ioC8Off uint16 = 0xCFFF ) -func (mmu *memoryManager) access(address uint16, activeMemory [256]memoryHandler) memoryHandler { +func (mmu *memoryManager) access(address uint16, activeMemory *[256]memoryHandler) memoryHandler { if address == ioC8Off { mmu.resetSlotExpansionRoms() } @@ -54,7 +54,7 @@ func (mmu *memoryManager) access(address uint16, activeMemory [256]memoryHandler // Peek returns the data on the given address func (mmu *memoryManager) Peek(address uint16) uint8 { - mh := mmu.access(address, mmu.activeMemoryRead) + mh := mmu.access(address, &mmu.activeMemoryRead) if mh == nil { return 0xf4 // Or some random number } @@ -63,7 +63,7 @@ func (mmu *memoryManager) Peek(address uint16) uint8 { // Poke sets the data at the given address func (mmu *memoryManager) Poke(address uint16, value uint8) { - mh := mmu.access(address, mmu.activeMemoryWrite) + mh := mmu.access(address, &mmu.activeMemoryWrite) if mh == nil { return }