From dbab733c773bb1a809ff1ce0c4445ba5003a25d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 25 Jan 2022 20:28:15 +0100 Subject: [PATCH] Explicitly use RPCDeviceList type for tracked list devices, for clarity. --- .../oc2/common/bus/RPCDeviceBusAdapter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/li/cil/oc2/common/bus/RPCDeviceBusAdapter.java b/src/main/java/li/cil/oc2/common/bus/RPCDeviceBusAdapter.java index f29c9c33..b16679bb 100644 --- a/src/main/java/li/cil/oc2/common/bus/RPCDeviceBusAdapter.java +++ b/src/main/java/li/cil/oc2/common/bus/RPCDeviceBusAdapter.java @@ -40,8 +40,8 @@ public final class RPCDeviceBusAdapter implements Steppable { private final ArrayList devices = new ArrayList<>(); private final HashMap devicesById = new HashMap<>(); - private final Set unmountedDevices = new HashSet<>(); - private final Set mountedDevices = new HashSet<>(); + private final Set unmountedDevices = new HashSet<>(); + private final Set mountedDevices = new HashSet<>(); private final Lock pauseLock = new ReentrantLock(); private boolean isPaused; @@ -163,7 +163,7 @@ public final class RPCDeviceBusAdapter implements Steppable { .add(identifier); }); - final Set newDevices = new HashSet<>(); + final Set newDevices = new HashSet<>(); identifiersByDevice.forEach((device, identifiers) -> { final UUID identifier = selectIdentifierDeterministically(identifiers); devices.add(new RPCDeviceWithIdentifier(identifier, device)); @@ -173,16 +173,16 @@ public final class RPCDeviceBusAdapter implements Steppable { // Add new devices to list of unmounted devices. List was cleared, so removed devices previously in // list of unmounted devices are already gone. - for (final RPCDevice newDevice : newDevices) { + for (final RPCDeviceList newDevice : newDevices) { if (!mountedDevices.contains(newDevice)) { unmountedDevices.add(newDevice); } } // Remove removed devices from list of mounted devices. - final Iterator mountedDeviceIterator = mountedDevices.iterator(); + final Iterator mountedDeviceIterator = mountedDevices.iterator(); while (mountedDeviceIterator.hasNext()) { - final RPCDevice device = mountedDeviceIterator.next(); + final RPCDeviceList device = mountedDeviceIterator.next(); if (!newDevices.contains(device)) { device.unmount(); mountedDeviceIterator.remove(); @@ -315,9 +315,9 @@ public final class RPCDeviceBusAdapter implements Steppable { } // Yes, we could hashmap this lookup, but the expectation is that we'll generally - // have relatively few methods per object where the overhead of hashing would not - // be worth it. So we just do a linear search, which also gives us maximal - // flexibility for free (devices may dynamically change their methods). + // have relatively few methods per object, so the overhead of hashing would not + // be worth it. Instead, we just do a quick linear search, which also gives us + // a lot of flexibility for free (devices may dynamically change their methods). final List fallbacks = new ArrayList<>(); String error = ERROR_UNKNOWN_METHOD; for (final RPCMethod method : device.getMethods()) {