aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/ARMeilleure/Common')
-rw-r--r--src/ARMeilleure/Common/ArenaAllocator.cs15
-rw-r--r--src/ARMeilleure/Common/BitMap.cs12
2 files changed, 15 insertions, 12 deletions
diff --git a/src/ARMeilleure/Common/ArenaAllocator.cs b/src/ARMeilleure/Common/ArenaAllocator.cs
index bce6794a..f810c2ab 100644
--- a/src/ARMeilleure/Common/ArenaAllocator.cs
+++ b/src/ARMeilleure/Common/ArenaAllocator.cs
@@ -82,8 +82,10 @@ namespace ARMeilleure.Common
}
else
{
- _page = new PageInfo();
- _page.Pointer = (byte*)NativeAllocator.Instance.Allocate(_pageSize);
+ _page = new PageInfo
+ {
+ Pointer = (byte*)NativeAllocator.Instance.Allocate(_pageSize),
+ };
_pages.Add(_page);
}
@@ -106,7 +108,7 @@ namespace ARMeilleure.Common
// Free excess pages that was allocated.
while (_pages.Count > _pageCount)
{
- NativeAllocator.Instance.Free(_pages[_pages.Count - 1].Pointer);
+ NativeAllocator.Instance.Free(_pages[^1].Pointer);
_pages.RemoveAt(_pages.Count - 1);
}
@@ -125,12 +127,13 @@ namespace ARMeilleure.Common
// If arena is used frequently, keep pages for longer. Otherwise keep pages for a shorter amount of time.
int now = Environment.TickCount;
- int count = (now - _lastReset) switch {
+ int count = (now - _lastReset) switch
+ {
>= 5000 => 0,
>= 2500 => 50,
>= 1000 => 100,
- >= 10 => 1500,
- _ => 5000
+ >= 10 => 1500,
+ _ => 5000,
};
for (int i = _pages.Count - 1; i >= 0; i--)
diff --git a/src/ARMeilleure/Common/BitMap.cs b/src/ARMeilleure/Common/BitMap.cs
index 27ef031f..94d47ea5 100644
--- a/src/ARMeilleure/Common/BitMap.cs
+++ b/src/ARMeilleure/Common/BitMap.cs
@@ -138,7 +138,7 @@ namespace ARMeilleure.Common
var newSpan = new Span<long>(_masks, _count);
oldSpan.CopyTo(newSpan);
- newSpan.Slice(oldSpan.Length).Clear();
+ newSpan[oldSpan.Length..].Clear();
_allocator.Free(oldMask);
}
@@ -176,8 +176,8 @@ namespace ARMeilleure.Common
private int _bit;
private readonly BitMap _map;
- public int Current => (int)_index * IntSize + _bit;
- object IEnumerator.Current => Current;
+ public readonly int Current => (int)_index * IntSize + _bit;
+ readonly object IEnumerator.Current => Current;
public Enumerator(BitMap map)
{
@@ -214,9 +214,9 @@ namespace ARMeilleure.Common
return true;
}
- public void Reset() { }
+ public readonly void Reset() { }
- public void Dispose() { }
+ public readonly void Dispose() { }
}
}
-} \ No newline at end of file
+}