mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +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
Notes:
sideshowbarker
2024-07-18 20:28:19 +09:00
Author: https://github.com/IdanHo
Commit: 2c93123daf
Pull-request: https://github.com/SerenityOS/serenity/pull/6167
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/bgianfo
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