From 5877208a57acf7c45e8dc71f07fc95250ac7a52b Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Mon, 20 Mar 2017 20:01:15 -0400 Subject: [PATCH] optimize writeUnitName (-130 bytes) --- src/Arduboy2.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index 58e8dcc..5b1fbd1 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -1014,17 +1014,14 @@ void Arduboy2Base::writeUnitName(char* name) for (uint8_t src = 0; src < ARDUBOY_UNIT_NAME_LEN; src++) { - if (name[src] != 0x00 && !done) - { - EEPROM.update(dest, name[src]); - } - else - { + if (name[src] == 0x00) { done = true; - EEPROM.update(dest, 0x00); } + // write character or 0 pad if finished + EEPROM.update(dest, done ? 0x00 : name[src]); dest++; } + } bool Arduboy2Base::readShowUnitNameFlag()