diff options
| author | David A. Mellis <d.mellis@arduino.cc> | 2010-11-11 23:29:21 -0500 | 
|---|---|---|
| committer | David A. Mellis <d.mellis@arduino.cc> | 2010-11-11 23:29:21 -0500 | 
| commit | 407d6bbc6fa9035dcb5e3b7b656eb3cbc871719d (patch) | |
| tree | 914d887f5b1b21567f546b2d95fede72a29a3e22 /cores/arduino/HardwareSerial.cpp | |
| parent | 08102b63704bc0ce4e89e1a2ec46aaa35f0af10a (diff) | |
Cast to encourage optimization of Serial ring buffer index calculations.
http://code.google.com/p/arduino/issues/detail?id=391
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
| -rw-r--r-- | cores/arduino/HardwareSerial.cpp | 6 | 
1 files changed, 3 insertions, 3 deletions
| diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index b25b4f1..4397efb 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -65,7 +65,7 @@ struct ring_buffer  inline void store_char(unsigned char c, ring_buffer *rx_buffer)  { -  int i = (rx_buffer->head + 1) % RX_BUFFER_SIZE; +  int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;    // if we should be storing the received character into the location    // just before the tail (meaning that the head would advance to the @@ -231,7 +231,7 @@ void HardwareSerial::end()  int HardwareSerial::available(void)  { -  return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE; +  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;  }  int HardwareSerial::peek(void) @@ -250,7 +250,7 @@ int HardwareSerial::read(void)      return -1;    } else {      unsigned char c = _rx_buffer->buffer[_rx_buffer->tail]; -    _rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE; +    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;      return c;    }  } | 
