mirror of
https://github.com/sethm/symon.git
synced 2025-04-14 05:37:39 +00:00
Optimization of Bus.isComplete()
This commit is contained in:
parent
d8deca227f
commit
bc6b93e3fe
@ -114,40 +114,14 @@ public class Bus {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop over devices and ensure they are contiguous.
|
||||
MemoryRange prev = null;
|
||||
int i = 0;
|
||||
int length = devices.size();
|
||||
// Loop over devices and add their size
|
||||
int filledMemory = 0;
|
||||
for (Device d : devices) {
|
||||
MemoryRange cur = d.getMemoryRange();
|
||||
if (i == 0) {
|
||||
// If the first entry doesn't start at 'startAddress', return false.
|
||||
if (cur.startAddress() != startAddress) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev != null && i < length - 1) {
|
||||
// Otherwise, compare previous map's end against this map's
|
||||
// endAddress. They must be adjacent!
|
||||
if (cur.startAddress() - 1 != prev.endAddress()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == length - 1) {
|
||||
// If the last entry doesn't end at endAddress, return false;
|
||||
if (cur.endAddress() != endAddress) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
prev = cur;
|
||||
filledMemory += d.getSize();
|
||||
}
|
||||
|
||||
// Must be complete.
|
||||
return true;
|
||||
// Returns if the total size of the devices fill the bus' memory space
|
||||
return filledMemory == endAddress - startAddress + 1;
|
||||
}
|
||||
|
||||
public int read(int address) throws MemoryAccessException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user