Slight improvement to the line parsing logic, saving 8 cycles per character
This commit is contained in:
parent
534bbb81ff
commit
2864ef8c7f
@ -1094,9 +1094,10 @@ inline void get_serial_commands() {
|
||||
/**
|
||||
* Loop while serial characters are incoming and the queue is not full
|
||||
*/
|
||||
while (commands_in_queue < BUFSIZE && MYSERIAL.available() > 0) {
|
||||
int c;
|
||||
while (commands_in_queue < BUFSIZE && (c = MYSERIAL.read()) >= 0) {
|
||||
|
||||
char serial_char = MYSERIAL.read();
|
||||
char serial_char = c;
|
||||
|
||||
/**
|
||||
* If the character ends the line
|
||||
@ -1196,9 +1197,9 @@ inline void get_serial_commands() {
|
||||
// The command will be injected when EOL is reached
|
||||
}
|
||||
else if (serial_char == '\\') { // Handle escapes
|
||||
if (MYSERIAL.available() > 0) {
|
||||
if ((c = MYSERIAL.read()) >= 0) {
|
||||
// if we have one more character, copy it over
|
||||
serial_char = MYSERIAL.read();
|
||||
serial_char = c;
|
||||
if (!serial_comment_mode) serial_line_buffer[serial_count++] = serial_char;
|
||||
}
|
||||
// otherwise do nothing
|
||||
|
Loading…
Reference in New Issue
Block a user