aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Memory/WindowsShared/MappingTree.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2022-08-30 22:26:40 -0300
committerMary-nyan <thog@protonmail.com>2022-09-10 16:23:49 +0200
commit7dd69f2d0e314b2969d88089559815ed84acbac4 (patch)
tree64dc59ff50f0fe4b8365fe70b2cbade27dd508f1 /Ryujinx.Memory/WindowsShared/MappingTree.cs
parentc646638680f9b2dcc055ffbb280e970fcfe93aab (diff)
Allocation free tree lookup
Diffstat (limited to 'Ryujinx.Memory/WindowsShared/MappingTree.cs')
-rw-r--r--Ryujinx.Memory/WindowsShared/MappingTree.cs20
1 files changed, 18 insertions, 2 deletions
diff --git a/Ryujinx.Memory/WindowsShared/MappingTree.cs b/Ryujinx.Memory/WindowsShared/MappingTree.cs
index 7a18d457..97758c2b 100644
--- a/Ryujinx.Memory/WindowsShared/MappingTree.cs
+++ b/Ryujinx.Memory/WindowsShared/MappingTree.cs
@@ -13,7 +13,7 @@ namespace Ryujinx.Memory.WindowsShared
public int GetNodes(ulong start, ulong end, ref RangeNode<T>[] overlaps, int overlapCount = 0)
{
- RangeNode<T> node = GetNode(new RangeNode<T>(start, start + 1UL, default));
+ RangeNode<T> node = this.GetNodeByKey(start);
for (; node != null; node = node.Successor)
{
@@ -34,7 +34,7 @@ namespace Ryujinx.Memory.WindowsShared
}
}
- class RangeNode<T> : IntrusiveRedBlackTreeNode<RangeNode<T>>, IComparable<RangeNode<T>>
+ class RangeNode<T> : IntrusiveRedBlackTreeNode<RangeNode<T>>, IComparable<RangeNode<T>>, IComparable<ulong>
{
public ulong Start { get; }
public ulong End { get; private set; }
@@ -67,5 +67,21 @@ namespace Ryujinx.Memory.WindowsShared
return 1;
}
}
+
+ public int CompareTo(ulong address)
+ {
+ if (address < Start)
+ {
+ return 1;
+ }
+ else if (address <= End - 1UL)
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
}
} \ No newline at end of file