code simplification
This commit is contained in:
1 parent
2217f3831d
commit
dc7dfc4b4d
1 file changed
+3
-8
@@ -79,18 +79,13 @@ public class Bus {
|
|||||||
int size = (this.endAddress - this.startAddress) + 1;
|
int size = (this.endAddress - this.startAddress) + 1;
|
||||||
deviceAddressArray = new Device[size];
|
deviceAddressArray = new Device[size];
|
||||||
|
|
||||||
List<Integer> priorities = new ArrayList<Integer>(deviceMap.keySet());
|
// getDevices() provides an OrderedSet with devices ordered by priorities
|
||||||
Collections.sort(priorities);
|
for(Device device : getDevices()) {
|
||||||
|
|
||||||
for(int priority : priorities) {
|
|
||||||
SortedSet<Device> deviceSet = deviceMap.get(priority);
|
|
||||||
for(Device device : deviceSet) {
|
|
||||||
MemoryRange range = device.getMemoryRange();
|
MemoryRange range = device.getMemoryRange();
|
||||||
for(int address = range.startAddress; address <= range.endAddress; ++address) {
|
for(int address = range.startAddress; address <= range.endAddress; ++address) {
|
||||||
deviceAddressArray[address - this.startAddress] = device;
|
deviceAddressArray[address - this.startAddress] = device;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +212,7 @@ public class Bus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<Device> getDevices() {
|
public SortedSet<Device> getDevices() {
|
||||||
// Expose a copy of the device list, not the original
|
// create an ordered set of devices, ordered by device priorities
|
||||||
SortedSet<Device> devices = new TreeSet<Device>();
|
SortedSet<Device> devices = new TreeSet<Device>();
|
||||||
|
|
||||||
List<Integer> priorities = new ArrayList<Integer>(deviceMap.keySet());
|
List<Integer> priorities = new ArrayList<Integer>(deviceMap.keySet());
|
||||||
|
|||||||
Reference in new issue
Block a user