mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-23 21:29:28 +00:00
memctrl: keep address_map sorted by address
We do a linear scan in find_range (which is called on all TLB misses) to find the entries. The largest and most frequently hit entry is the system memory (which starts at 0). By ensuring that it's the first entry in the list, we end up only doing one iteration through the loop.
This commit is contained in:
parent
f192d11758
commit
9b49603c72
@ -168,7 +168,18 @@ bool MemCtrlBase::add_mem_region(uint32_t start_addr, uint32_t size,
|
||||
entry->devobj = nullptr;
|
||||
entry->mem_ptr = reg_content;
|
||||
|
||||
this->address_map.push_back(entry);
|
||||
// Keep address_map sorted, that way the RAM region (which starts at 0 and
|
||||
// is most often requested) will be found by find_range on the first
|
||||
// iteration.
|
||||
this->address_map.insert(
|
||||
std::upper_bound(
|
||||
this->address_map.begin(),
|
||||
this->address_map.end(),
|
||||
entry,
|
||||
[](const auto& lhs, const auto& rhs) {
|
||||
return lhs->start < rhs->start;
|
||||
}),
|
||||
entry);
|
||||
|
||||
LOG_F(INFO, "Added mem region 0x%X..0x%X (%s%s%s%s) -> 0x%X", start_addr, end,
|
||||
entry->type & RT_ROM ? "ROM," : "",
|
||||
|
Loading…
Reference in New Issue
Block a user