mirror of
https://github.com/sethm/symon.git
synced 2024-06-07 19:29:27 +00:00
code simplification
This commit is contained in:
parent
2217f3831d
commit
dc7dfc4b4d
|
@ -78,17 +78,12 @@ public class Bus {
|
|||
private void buildDeviceAddressArray() {
|
||||
int size = (this.endAddress - this.startAddress) + 1;
|
||||
deviceAddressArray = new Device[size];
|
||||
|
||||
List<Integer> priorities = new ArrayList<Integer>(deviceMap.keySet());
|
||||
Collections.sort(priorities);
|
||||
|
||||
for(int priority : priorities) {
|
||||
SortedSet<Device> deviceSet = deviceMap.get(priority);
|
||||
for(Device device : deviceSet) {
|
||||
MemoryRange range = device.getMemoryRange();
|
||||
for(int address = range.startAddress; address <= range.endAddress; ++address) {
|
||||
deviceAddressArray[address - this.startAddress] = device;
|
||||
}
|
||||
|
||||
// getDevices() provides an OrderedSet with devices ordered by priorities
|
||||
for(Device device : getDevices()) {
|
||||
MemoryRange range = device.getMemoryRange();
|
||||
for(int address = range.startAddress; address <= range.endAddress; ++address) {
|
||||
deviceAddressArray[address - this.startAddress] = device;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +212,7 @@ public class Bus {
|
|||
}
|
||||
|
||||
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>();
|
||||
|
||||
List<Integer> priorities = new ArrayList<Integer>(deviceMap.keySet());
|
||||
|
|
Loading…
Reference in New Issue
Block a user