aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Memory/Range
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-10-04 19:38:59 +0100
committerGitHub <noreply@github.com>2021-10-04 15:38:59 -0300
commitfff48bb45a197e4c1307340112cfed7fd45f5a83 (patch)
treecac718838e9da631541d9a73293ed026cb8b8cdb /Ryujinx.Memory/Range
parent75f4b1ff2de8d8bd57dd84f2c3cb4cb3c353b93b (diff)
Smaller initial size for ModifiedRangeList & directly inherit range list (#2663)
This fixes a potential regression with the new range list changes, where the cost for creating new ones would be rather large due to creating a 1024 size array. Also reduces cost for range list inheritance by using the first existing range list as a base, rather than creating a new one then adding both lists to it. The growth size for the RangeList is now identical to its initial size. Every 32 elements was probably a little too common - now it is 1024 for most things and 8 for the buffer modified range list. The Unmapped and SyncMethod methods have been changed to ensure that they behave properly if the range list is set null. Cleaned up a few calls to use the null-conditional operator.
Diffstat (limited to 'Ryujinx.Memory/Range')
-rw-r--r--Ryujinx.Memory/Range/RangeList.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Ryujinx.Memory/Range/RangeList.cs b/Ryujinx.Memory/Range/RangeList.cs
index d82a05c5..7278e7eb 100644
--- a/Ryujinx.Memory/Range/RangeList.cs
+++ b/Ryujinx.Memory/Range/RangeList.cs
@@ -33,18 +33,22 @@ namespace Ryujinx.Memory.Range
}
}
+ private const int BackingInitialSize = 1024;
private const int ArrayGrowthSize = 32;
- private const int BackingGrowthSize = 1024;
private RangeItem<T>[] _items;
+ private readonly int _backingGrowthSize;
+
public int Count { get; protected set; }
/// <summary>
/// Creates a new range list.
/// </summary>
- public RangeList()
+ /// <param name="backingInitialSize">The initial size of the backing array</param>
+ public RangeList(int backingInitialSize = BackingInitialSize)
{
- _items = new RangeItem<T>[BackingGrowthSize];
+ _backingGrowthSize = backingInitialSize;
+ _items = new RangeItem<T>[backingInitialSize];
}
/// <summary>
@@ -68,7 +72,7 @@ namespace Ryujinx.Memory.Range
{
if (Count + 1 > _items.Length)
{
- Array.Resize(ref _items, _items.Length + ArrayGrowthSize);
+ Array.Resize(ref _items, _items.Length + _backingGrowthSize);
}
if (index >= Count)