mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-21 10:52:14 +01:00
Use Math.min instead of ternary if in Serial data copy
This makes the code slightly more compact and easier to read.
This commit is contained in:
parent
d6667dd4ca
commit
d244a45c4a
@ -191,8 +191,7 @@ public class Serial implements SerialPortEventListener {
|
||||
int next = 0;
|
||||
while(next < buf.length) {
|
||||
while(next < buf.length && outToMessage.hasRemaining()) {
|
||||
int spaceInIn = inFromSerial.remaining();
|
||||
int copyNow = buf.length - next < spaceInIn ? buf.length - next : spaceInIn;
|
||||
int copyNow = Math.min(buf.length - next, inFromSerial.remaining());
|
||||
inFromSerial.put(buf, next, copyNow);
|
||||
next += copyNow;
|
||||
inFromSerial.flip();
|
||||
|
Loading…
x
Reference in New Issue
Block a user