diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2014-04-23 17:45:10 +0200 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2015-01-26 17:03:25 +0100 |
commit | b6ba4b6aab4f5886866bd125a2e09940892dcac6 (patch) | |
tree | 7fd1d5a6c3f83b33c369369c40a405032c48a09a | |
parent | 03f242b231824daa3fce38811cd9d3cf7e4e7e21 (diff) |
In SoftwareSerial::recv, only calculate the new tail once
This shortens the generated code a bit more.
-rw-r--r-- | libraries/SoftwareSerial/SoftwareSerial.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index cafd0c4..42f796b 100644 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -259,11 +259,12 @@ void SoftwareSerial::recv() d = ~d;
// if buffer full, set the overflow flag and return
- if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head)
+ uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
+ if (next != _receive_buffer_head)
{
// save new data in buffer: tail points to where byte goes
_receive_buffer[_receive_buffer_tail] = d; // save new byte
- _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
+ _receive_buffer_tail = next;
}
else
{
|