Optimized comment stripper code

This commit is contained in:
ProDrone 2015-05-14 00:11:31 +02:00
parent 1df9097e32
commit 0ee67a521b
1 changed files with 8 additions and 7 deletions

View File

@ -1712,11 +1712,13 @@ void cliProcess(void)
// Strip comment starting with # from line // Strip comment starting with # from line
char *p = cliBuffer; char *p = cliBuffer;
p = strchr(++p, '#'); p = strchr(p, '#');
if (NULL != p) { if (NULL != p) {
bufferIndex = (uint32_t)(p - cliBuffer); bufferIndex = (uint32_t)(p - cliBuffer);
} }
// Process non-empty lines
if (bufferIndex > 0) {
// Strip trailing whitespace // Strip trailing whitespace
while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') { while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') {
bufferIndex--; bufferIndex--;
@ -1724,7 +1726,6 @@ void cliProcess(void)
cliBuffer[bufferIndex] = 0; // null terminate cliBuffer[bufferIndex] = 0; // null terminate
if (cliBuffer[0] != '#') {
target.name = cliBuffer; target.name = cliBuffer;
target.param = NULL; target.param = NULL;