Skip to content

Commit 990e934

Browse files
Use Math.min instead of ternary if in Serial data copy
This makes the code slightly more compact and easier to read.
1 parent b40f54a commit 990e934

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
@@ -178,8 +178,7 @@ public synchronized void serialEvent(SerialPortEvent serialEvent) {
178178
int next = 0;
179179
while(next < buf.length) {
180180
while(next < buf.length && outToMessage.hasRemaining()) {
181-
int spaceInIn = inFromSerial.remaining();
182-
int copyNow = buf.length - next < spaceInIn ? buf.length - next : spaceInIn;
181+
int copyNow = Math.min(buf.length - next, inFromSerial.remaining());
183182
inFromSerial.put(buf, next, copyNow);
184183
next += copyNow;
185184
inFromSerial.flip();

0 commit comments

Comments
 (0)