diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2020-02-26 20:38:08 +0300 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2020-03-24 17:24:50 +0300 |
commit | d244a45c4a83a8eaa97a1048ad61be718533c64f (patch) | |
tree | f0825e68dfa8827fab289e9655bf67227dcaf187 /arduino-core | |
parent | d6667dd4caac7aa67693ebce925a36806ce00618 (diff) |
Use Math.min instead of ternary if in Serial data copy
This makes the code slightly more compact and easier to read.
Diffstat (limited to 'arduino-core')
-rw-r--r-- | arduino-core/src/processing/app/Serial.java | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arduino-core/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java index 1ea670950..b79af2d2a 100644 --- a/arduino-core/src/processing/app/Serial.java +++ b/arduino-core/src/processing/app/Serial.java @@ -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(); |