From 8bdd6941adcf22dbc56d8d7c78bc08cc5913d186 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 5 Mar 2017 18:26:32 +0100 Subject: [PATCH] Avoid allocations in MMU#[] --- lib/waterfoul/mmu.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/waterfoul/mmu.rb b/lib/waterfoul/mmu.rb index 3ffbdcf..08d9dad 100644 --- a/lib/waterfoul/mmu.rb +++ b/lib/waterfoul/mmu.rb @@ -32,12 +32,12 @@ module Waterfoul if i == 0xFF00 Input.read_keyboard @memory[i] - elsif (0x8000...0xA000) === i or (0xC000...0xE000) === i or (0xFE00..0xFFFF) === i + elsif i >= 0x8000 && i < 0xA000 or i >= 0xC000 && i < 0xE000 or i >= 0xFE00 @memory[i] - elsif (0xE000...0xFE00) === i - @memory[i - 0x2000] - elsif (0x0000...0x8000) === i or (0xA000...0xC000) === i + elsif i < 0x8000 or i >= 0xA000 && i < 0xC000 @cartridge[i] + else # if (0xE000...0xFE00) === i + @memory[i - 0x2000] end end