mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 09:54:57 +00:00
Kernel: Replace process' regions vector with a Red Black tree
This should provide some speed up, as currently searches for regions containing a given address were performed in O(n) complexity, while this container allows us to do those in O(logn).
This commit is contained in:
parent
497c759ab7
commit
2c93123daf
7 changed files with 89 additions and 97 deletions
|
@ -433,13 +433,8 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
|
|||
|
||||
Region* MemoryManager::user_region_from_vaddr(Space& space, VirtualAddress vaddr)
|
||||
{
|
||||
// FIXME: Use a binary search tree (maybe red/black?) or some other more appropriate data structure!
|
||||
ScopedSpinLock lock(space.get_lock());
|
||||
for (auto& region : space.regions()) {
|
||||
if (region.contains(vaddr))
|
||||
return ®ion;
|
||||
}
|
||||
return nullptr;
|
||||
return space.find_region_containing({ vaddr, 1 });
|
||||
}
|
||||
|
||||
Region* MemoryManager::find_region_from_vaddr(Space& space, VirtualAddress vaddr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue