Skip to content

Commit d244a45

Browse files
matthijskooijmancmaglie
authored andcommitted
Use Math.min instead of ternary if in Serial data copy
This makes the code slightly more compact and easier to read.
1 parent d6667dd commit d244a45

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Diff for: arduino-core/src/processing/app/Serial.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ public void processSerialEvent(byte[] buf) {
191191
int next = 0;
192192
while(next < buf.length) {
193193
while(next < buf.length && outToMessage.hasRemaining()) {
194-
int spaceInIn = inFromSerial.remaining();
195-
int copyNow = buf.length - next < spaceInIn ? buf.length - next : spaceInIn;
194+
int copyNow = Math.min(buf.length - next, inFromSerial.remaining());
196195
inFromSerial.put(buf, next, copyNow);
197196
next += copyNow;
198197
inFromSerial.flip();

0 commit comments

Comments
 (0)