From 420f745bed3d02a29b3d23ad6bde351a36499773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 18 Feb 2023 09:50:22 +0000 Subject: [PATCH] optimisation: mmu: combine if statements Change in memory: Flash: -6 bytes SRAM: 0 bytes --- Firmware/mmu2_protocol_logic.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 441cdec1e..b7203fa5d 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -705,9 +705,8 @@ void ProtocolLogic::FormatLastResponseMsgAndClearLRB(char *dst) { *dst++ = '<'; for (uint8_t i = 0; i < lrb; ++i) { uint8_t b = lastReceivedBytes[i]; - if (b < 32) - b = '.'; - if (b > 127) + // Check for printable character, including space + if (b < 32 || b > 127) b = '.'; *dst++ = b; } @@ -721,9 +720,8 @@ void ProtocolLogic::LogRequestMsg(const uint8_t *txbuff, uint8_t size) { static char lastMsg[rqs] = ""; for (uint8_t i = 0; i < size; ++i) { uint8_t b = txbuff[i]; - if (b < 32) - b = '.'; - if (b > 127) + // Check for printable character, including space + if (b < 32 || b > 127) b = '.'; tmp[i + 1] = b; }