Consolidate IsInvalid check

This commit is contained in:
Gabriel A 2024-07-31 22:37:52 -03:00
commit a8862fc7cf
3 changed files with 15 additions and 15 deletions

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Memory.Range
{ {
MemoryRange subRange = Range.GetSubRange(index); MemoryRange subRange = Range.GetSubRange(index);
if (subRange.Address != ulong.MaxValue) if (!MemoryRange.IsInvalid(ref subRange))
{ {
return subRange.Address; return subRange.Address;
} }

View file

@ -58,6 +58,17 @@ namespace Ryujinx.Memory.Range
return thisAddress < otherEndAddress && otherAddress < thisEndAddress; return thisAddress < otherEndAddress && otherAddress < thisEndAddress;
} }
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to checl</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
internal static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == ulong.MaxValue;
}
/// <summary> /// <summary>
/// Returns a string summary of the memory range. /// Returns a string summary of the memory range.
/// </summary> /// </summary>

View file

@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@ -142,17 +142,6 @@ namespace Ryujinx.Memory.Range
return overlapCount; return overlapCount;
} }
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to checl</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
private static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == ulong.MaxValue;
}
/// <summary> /// <summary>
/// Gets all items on the list starting at the specified memory address. /// Gets all items on the list starting at the specified memory address.
/// </summary> /// </summary>