From bac3168ca4a5278f4d49e20881715ba8afd205d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 19 Aug 2022 23:01:02 +0000 Subject: [PATCH] Optimise power_on and power_off eeprom_update_byte only updates the EEPROM if the value is different Saves 40 bytes of flash memory --- Firmware/mmu2_power.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Firmware/mmu2_power.cpp b/Firmware/mmu2_power.cpp index 405f0d7c3..a0359f016 100644 --- a/Firmware/mmu2_power.cpp +++ b/Firmware/mmu2_power.cpp @@ -12,18 +12,12 @@ namespace MMU2 { // so we just block the MMU via EEPROM var instead. void power_on() { - if (!eeprom_read_byte((uint8_t *)EEPROM_MMU_ENABLED)) - { - eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, true); - } + eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, true); } void power_off() { - if (eeprom_read_byte((uint8_t *)EEPROM_MMU_ENABLED)) - { - eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false); - } + eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false); } void reset() {