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;
|
int next = 0;
|
||||||
while(next < buf.length) {
|
while(next < buf.length) {
|
||||||
while(next < buf.length && outToMessage.hasRemaining()) {
|
while(next < buf.length && outToMessage.hasRemaining()) {
|
||||||
int spaceInIn = inFromSerial.remaining();
|
int copyNow = Math.min(buf.length - next, inFromSerial.remaining());
|
||||||
int copyNow = buf.length - next < spaceInIn ? buf.length - next : spaceInIn;
|
|
||||||
inFromSerial.put(buf, next, copyNow);
|
inFromSerial.put(buf, next, copyNow);
|
||||||
next += copyNow;
|
next += copyNow;
|
||||||
inFromSerial.flip();
|
inFromSerial.flip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user