Merge duplicate strings in cmdqueue.cpp

Original idea from @GilesBathgate, PR #3322 . This is just a rework on top of current MK3 branch.
This commit is contained in:
D.R.racer 2023-02-18 11:37:48 +01:00
parent 3381bf2f7e
commit ee23d6c62a
1 changed files with 7 additions and 4 deletions

View File

@ -248,6 +248,9 @@ void cmdqueue_dump_to_serial()
} }
#endif /* CMDBUFFER_DEBUG */ #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 //adds an command to the main command buffer
//thats really done in a non-safe way. //thats really done in a non-safe way.
//needs overworking someday //needs overworking someday
@ -283,7 +286,7 @@ void enquecommand(const char *cmd, bool from_progmem)
SERIAL_PROTOCOLRPGM(cmd); SERIAL_PROTOCOLRPGM(cmd);
else else
SERIAL_ECHO(cmd); SERIAL_ECHO(cmd);
SERIAL_ECHOLNPGM("\" failed: Buffer full!"); SERIAL_ECHOLNRPGM(bufferFull);
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
cmdqueue_dump_to_serial(); cmdqueue_dump_to_serial();
#endif /* CMDBUFFER_DEBUG */ #endif /* CMDBUFFER_DEBUG */
@ -307,7 +310,7 @@ void enquecommand_front(const char *cmd, bool from_progmem)
strcpy(cmdbuffer + bufindr + CMDHDRSIZE, cmd); strcpy(cmdbuffer + bufindr + CMDHDRSIZE, cmd);
++ buflen; ++ buflen;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPGM("Enqueing to the front: \""); SERIAL_ECHORPGM(enqueingFront);
SERIAL_ECHO(cmdbuffer + bufindr + CMDHDRSIZE); SERIAL_ECHO(cmdbuffer + bufindr + CMDHDRSIZE);
SERIAL_ECHOLNPGM("\""); SERIAL_ECHOLNPGM("\"");
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
@ -315,12 +318,12 @@ void enquecommand_front(const char *cmd, bool from_progmem)
#endif /* CMDBUFFER_DEBUG */ #endif /* CMDBUFFER_DEBUG */
} else { } else {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ECHOPGM("Enqueing to the front: \""); SERIAL_ECHORPGM(enqueingFront);
if (from_progmem) if (from_progmem)
SERIAL_PROTOCOLRPGM(cmd); SERIAL_PROTOCOLRPGM(cmd);
else else
SERIAL_ECHO(cmd); SERIAL_ECHO(cmd);
SERIAL_ECHOLNPGM("\" failed: Buffer full!"); SERIAL_ECHOLNRPGM(bufferFull);
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
cmdqueue_dump_to_serial(); cmdqueue_dump_to_serial();
#endif /* CMDBUFFER_DEBUG */ #endif /* CMDBUFFER_DEBUG */