From bc37866ac946bc9c7b72970c341ffadfb1086e8b Mon Sep 17 00:00:00 2001
From: LotP1 <68976644+LotP1@users.noreply.github.com>
Date: Wed, 4 Jun 2025 02:13:31 +0200
Subject: [PATCH] remove duplicate function
BinarySearchLeftEdge(ulong address) matches BinarySearch(ulong address), so the former is not needed
---
src/Ryujinx.Memory/Range/RangeList.cs | 75 ++-------------------------
1 file changed, 3 insertions(+), 72 deletions(-)
diff --git a/src/Ryujinx.Memory/Range/RangeList.cs b/src/Ryujinx.Memory/Range/RangeList.cs
index c2e39b576..a1df8f142 100644
--- a/src/Ryujinx.Memory/Range/RangeList.cs
+++ b/src/Ryujinx.Memory/Range/RangeList.cs
@@ -93,7 +93,7 @@ namespace Ryujinx.Memory.Range
/// True if the item was located and updated, false otherwise
protected bool Update(T item)
{
- int index = BinarySearchLeftEdge(item.Address);
+ int index = BinarySearch(item.Address);
if (index >= 0)
{
@@ -184,7 +184,7 @@ namespace Ryujinx.Memory.Range
/// True if the item was removed, or false if it was not found
public bool Remove(T item)
{
- int index = BinarySearchLeftEdge(item.Address);
+ int index = BinarySearch(item.Address);
if (index >= 0)
{
@@ -264,7 +264,7 @@ namespace Ryujinx.Memory.Range
ulong endAddress = address + size;
- int startIndex = BinarySearchLeftEdge(address);
+ int startIndex = BinarySearch(address);
if (startIndex < 0)
startIndex = ~startIndex;
int endIndex = -1;
@@ -444,75 +444,6 @@ namespace Ryujinx.Memory.Range
return ~left;
}
- ///
- /// Performs binary search on the internal list of items.
- ///
- /// Address to find
- /// List index of the left-most item that overlaps, or complement index of nearest item with lower value on the list
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private int BinarySearchLeftEdge(ulong address)
- {
- if (Count == 0)
- return ~0;
-
- if (Count == 1)
- {
- ref RangeItem item = ref _items[0];
-
- if (address == item.Address)
- {
- return 0;
- }
- if (address < item.Address)
- {
- return ~0;
- }
- else
- {
- return ~1;
- }
- }
-
- int left = 0;
- int right = Count - 1;
-
- while (left <= right)
- {
- int range = right - left;
-
- int middle = left + (range >> 1);
-
- ref RangeItem item = ref _items[middle];
-
- bool match = item.Address == address;
-
- if (range == 0)
- {
- if (match)
- return middle;
- else if (address < item.Address)
- return ~(right);
- else
- return ~(right + 1);
- }
-
- if (match)
- {
- right = middle;
- }
- else if (address < item.Address)
- {
- right = middle - 1;
- }
- else
- {
- left = middle + 1;
- }
- }
-
- return ~left;
- }
-
///
/// Performs binary search on the internal list of items.
///