mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 00:16:23 +02:00
update comments and remove unused functions
This commit is contained in:
parent
bc37866ac9
commit
373fa30535
1 changed files with 5 additions and 154 deletions
|
@ -257,7 +257,7 @@ namespace Ryujinx.Memory.Range
|
|||
/// <param name="address">Start address of the range</param>
|
||||
/// <param name="size">Size in bytes of the range</param>
|
||||
/// <param name="output">Output array where matches will be written. It is automatically resized to fit the results</param>
|
||||
/// <returns>The number of overlapping items found</returns>
|
||||
/// <returns>Range information of overlapping items found</returns>
|
||||
public OverlapResult FindOverlaps(ulong address, ulong size, ref RangeItem<T>[] output)
|
||||
{
|
||||
int outputIndex = 0;
|
||||
|
@ -323,7 +323,7 @@ namespace Ryujinx.Memory.Range
|
|||
/// <param name="address">Start address of the range</param>
|
||||
/// <param name="size">Size in bytes of the range</param>
|
||||
/// <param name="output">Output array where matches will be written. It is automatically resized to fit the results</param>
|
||||
/// <returns>The number of overlapping items found</returns>
|
||||
/// <returns>Range information of overlapping items found</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public OverlapResult FindOverlapsNonOverlapping(ulong address, ulong size, ref RangeItem<T>[] output)
|
||||
{
|
||||
|
@ -364,7 +364,7 @@ namespace Ryujinx.Memory.Range
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets range of all items on the list overlapping the specified memory range.
|
||||
/// Gets the range of all items on the list overlapping the specified memory range.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method only returns correct results if none of the items on the list overlaps with
|
||||
|
@ -387,26 +387,6 @@ namespace Ryujinx.Memory.Range
|
|||
return new OverlapResult(index, endIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all items on the list with the specified memory address.
|
||||
/// </summary>
|
||||
/// <param name="address">Address to find</param>
|
||||
/// <param name="output">Output array where matches will be written. It is automatically resized to fit the results</param>
|
||||
/// <returns>The number of matches found</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public OverlapResult FindOverlaps(ulong address, ref RangeItem<T>[] output)
|
||||
{
|
||||
(int index, int endIndex) = BinarySearchEdges(address);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
Array.Resize(ref output, endIndex - index);
|
||||
Array.Copy(_items, index, output, 0, endIndex - index);
|
||||
}
|
||||
|
||||
return new OverlapResult(index, endIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs binary search on the internal list of items.
|
||||
/// </summary>
|
||||
|
@ -443,136 +423,7 @@ namespace Ryujinx.Memory.Range
|
|||
|
||||
return ~left;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs binary search on the internal list of items.
|
||||
/// </summary>
|
||||
/// <param name="address">Start address of the range</param>
|
||||
/// <returns>List index of the left-most item that overlaps, or complement index of nearest item with lower value on the list</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private (int, int) BinarySearchEdges(ulong address)
|
||||
{
|
||||
if (Count == 0)
|
||||
return (~0, ~0);
|
||||
|
||||
if (Count == 1)
|
||||
{
|
||||
ref RangeItem<T> item = ref _items[0];
|
||||
|
||||
if (item.Address == address)
|
||||
{
|
||||
return (0, 1);
|
||||
}
|
||||
|
||||
if (address < item.Address)
|
||||
{
|
||||
return (~0, ~0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (~1, ~1);
|
||||
}
|
||||
}
|
||||
|
||||
int left = 0;
|
||||
int right = Count - 1;
|
||||
|
||||
int leftEdge = -1;
|
||||
int rightEdgeMatch = -1;
|
||||
int rightEdgeNoMatch = -1;
|
||||
|
||||
while (left <= right)
|
||||
{
|
||||
int range = right - left;
|
||||
|
||||
int middle = left + (range >> 1);
|
||||
|
||||
ref RangeItem<T> item = ref _items[middle];
|
||||
|
||||
bool match = item.Address == address;
|
||||
|
||||
if (range == 0)
|
||||
{
|
||||
if (match)
|
||||
{
|
||||
leftEdge = middle;
|
||||
break;
|
||||
}
|
||||
else if (address < item.Address)
|
||||
{
|
||||
return (~right, ~right);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (~(right + 1), ~(right + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
right = middle;
|
||||
if (rightEdgeMatch == -1)
|
||||
rightEdgeMatch = middle;
|
||||
}
|
||||
else if (address < item.Address)
|
||||
{
|
||||
right = middle - 1;
|
||||
rightEdgeNoMatch = middle;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = middle + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (left > right)
|
||||
{
|
||||
return (~left, ~left);
|
||||
}
|
||||
|
||||
if (rightEdgeMatch == -1)
|
||||
{
|
||||
return (leftEdge, leftEdge + 1);
|
||||
}
|
||||
|
||||
left = rightEdgeMatch;
|
||||
right = rightEdgeNoMatch > 0 ? rightEdgeNoMatch : Count - 1;
|
||||
|
||||
while (left <= right)
|
||||
{
|
||||
int range = right - left;
|
||||
|
||||
int middle = right - (range >> 1);
|
||||
|
||||
ref RangeItem<T> item = ref _items[middle];
|
||||
|
||||
bool match = item.Address == address;
|
||||
|
||||
if (range == 0)
|
||||
{
|
||||
if (match)
|
||||
return (leftEdge, middle + 1);
|
||||
else
|
||||
return (leftEdge, middle);
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
left = middle;
|
||||
}
|
||||
else if (address < item.Address)
|
||||
{
|
||||
right = middle - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = middle + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return (leftEdge, right + 1);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Performs binary search for items overlapping a given memory range.
|
||||
/// </summary>
|
||||
|
@ -616,7 +467,7 @@ namespace Ryujinx.Memory.Range
|
|||
/// </summary>
|
||||
/// <param name="address">Start address of the range</param>
|
||||
/// <param name="endAddress">End address of the range</param>
|
||||
/// <returns>List index of the left-most item that overlaps, or complement index of nearest item with lower value on the list</returns>
|
||||
/// <returns>Range information (inclusive, exclusive) of items that overlaps, or complement index of nearest item with lower value on the list</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private (int, int) BinarySearchEdges(ulong address, ulong endAddress)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue