1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +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:
Idan Horowitz 2021-04-07 02:20:29 +03:00 committed by Andreas Kling
parent 497c759ab7
commit 2c93123daf
7 changed files with 89 additions and 97 deletions

View file

@ -27,7 +27,7 @@
#pragma once
#include <AK/NonnullOwnPtrVector.h>
#include <AK/RedBlackTree.h>
#include <AK/Vector.h>
#include <AK/WeakPtr.h>
#include <Kernel/UnixTypes.h>
@ -48,8 +48,8 @@ public:
size_t region_count() const { return m_regions.size(); }
NonnullOwnPtrVector<Region>& regions() { return m_regions; }
const NonnullOwnPtrVector<Region>& regions() const { return m_regions; }
RedBlackTree<FlatPtr, NonnullOwnPtr<Region>>& regions() { return m_regions; }
const RedBlackTree<FlatPtr, NonnullOwnPtr<Region>>& regions() const { return m_regions; }
void dump_regions();
@ -91,7 +91,7 @@ private:
RefPtr<PageDirectory> m_page_directory;
NonnullOwnPtrVector<Region> m_regions;
RedBlackTree<FlatPtr, NonnullOwnPtr<Region>> m_regions;
struct RegionLookupCache {
Optional<Range> range;