From ee23d6c62a104f8d4de0ff1e16c084c1c45e7a50 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Sat, 18 Feb 2023 11:37:48 +0100 Subject: [PATCH] Merge duplicate strings in cmdqueue.cpp Original idea from @GilesBathgate, PR #3322 . This is just a rework on top of current MK3 branch. --- Firmware/cmdqueue.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 105d57465..cd5a3c348 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -248,6 +248,9 @@ void cmdqueue_dump_to_serial() } #endif /* CMDBUFFER_DEBUG */ +static const char bufferFull[] PROGMEM = "\" failed: Buffer full!"; +static const char enqueingFront[] PROGMEM = "Enqueing to the front: \""; + //adds an command to the main command buffer //thats really done in a non-safe way. //needs overworking someday @@ -283,7 +286,7 @@ void enquecommand(const char *cmd, bool from_progmem) SERIAL_PROTOCOLRPGM(cmd); else SERIAL_ECHO(cmd); - SERIAL_ECHOLNPGM("\" failed: Buffer full!"); + SERIAL_ECHOLNRPGM(bufferFull); #ifdef CMDBUFFER_DEBUG cmdqueue_dump_to_serial(); #endif /* CMDBUFFER_DEBUG */ @@ -307,7 +310,7 @@ void enquecommand_front(const char *cmd, bool from_progmem) strcpy(cmdbuffer + bufindr + CMDHDRSIZE, cmd); ++ buflen; SERIAL_ECHO_START; - SERIAL_ECHOPGM("Enqueing to the front: \""); + SERIAL_ECHORPGM(enqueingFront); SERIAL_ECHO(cmdbuffer + bufindr + CMDHDRSIZE); SERIAL_ECHOLNPGM("\""); #ifdef CMDBUFFER_DEBUG @@ -315,12 +318,12 @@ void enquecommand_front(const char *cmd, bool from_progmem) #endif /* CMDBUFFER_DEBUG */ } else { SERIAL_ERROR_START; - SERIAL_ECHOPGM("Enqueing to the front: \""); + SERIAL_ECHORPGM(enqueingFront); if (from_progmem) SERIAL_PROTOCOLRPGM(cmd); else SERIAL_ECHO(cmd); - SERIAL_ECHOLNPGM("\" failed: Buffer full!"); + SERIAL_ECHOLNRPGM(bufferFull); #ifdef CMDBUFFER_DEBUG cmdqueue_dump_to_serial(); #endif /* CMDBUFFER_DEBUG */