Skip to content

Commit 5fc0eae

Browse files
committed
Slightly optimized method by removing redundant boolean flag
1 parent 19598fa commit 5fc0eae

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

arduino-core/src/cc/arduino/packages/discoverers/serial/SerialDiscovery.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,18 @@ public synchronized void forceRefresh() {
162162
Map<String, Object> boardData = platform.resolveDeviceByVendorIdProductId(port, BaseNoGui.packages);
163163

164164
BoardPort boardPort = null;
165-
boolean updatingInfos = false;
166165
int i = 0;
167166
// create new board or update existing
168167
for (BoardPort board : boardPorts) {
169168
if (board.toString().equals(newPort)) {
170-
updatingInfos = true;
171169
boardPort = boardPorts.get(i);
172170
break;
173171
}
174172
i++;
175173
}
176-
if (!updatingInfos) {
174+
if (boardPort == null) {
177175
boardPort = new BoardPort();
176+
boardPorts.add(boardPort);
178177
}
179178
boardPort.setAddress(port);
180179
boardPort.setProtocol("serial");
@@ -216,9 +215,6 @@ public synchronized void forceRefresh() {
216215
}
217216

218217
boardPort.setLabel(label);
219-
if (!updatingInfos) {
220-
boardPorts.add(boardPort);
221-
}
222218
}
223219
setSerialBoardPorts(boardPorts);
224220
}

0 commit comments

Comments
 (0)