From 7969fb6bbaf49a7a84df379d072b94286e4f7ada Mon Sep 17 00:00:00 2001 From: jhorv <38920027+jhorv@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:09:08 -0400 Subject: Replace and remove obsolete ByteMemoryPool type (#7155) * refactor: replace usage of ByteMemoryPool with MemoryOwner * refactor: delete unused ByteMemoryPool and ByteMemoryPool.ByteMemoryPoolBuffer types * refactor: change IMemoryOwner return types to MemoryOwner * fix(perf): get span via `MemoryOwner.Span` directly instead of `MemoryOwner.Memory.Span` * fix(perf): get span via MemoryOwner.Span directly instead of `MemoryOwner.Memory.Span` * fix(perf): get span via MemoryOwner.Span directly instead of `MemoryOwner.Memory.Span` --- .../Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs | 51 ---------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/Ryujinx.Common/Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs (limited to 'src/Ryujinx.Common/Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs') diff --git a/src/Ryujinx.Common/Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs b/src/Ryujinx.Common/Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs deleted file mode 100644 index 05fb29ac..00000000 --- a/src/Ryujinx.Common/Memory/ByteMemoryPool.ByteMemoryPoolBuffer.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Buffers; -using System.Threading; - -namespace Ryujinx.Common.Memory -{ - public partial class ByteMemoryPool - { - /// - /// Represents a that wraps an array rented from - /// and exposes it as - /// with a length of the requested size. - /// - private sealed class ByteMemoryPoolBuffer : IMemoryOwner - { - private byte[] _array; - private readonly int _length; - - public ByteMemoryPoolBuffer(int length) - { - _array = ArrayPool.Shared.Rent(length); - _length = length; - } - - /// - /// Returns a belonging to this owner. - /// - public Memory Memory - { - get - { - byte[] array = _array; - - ObjectDisposedException.ThrowIf(array is null, this); - - return new Memory(array, 0, _length); - } - } - - public void Dispose() - { - var array = Interlocked.Exchange(ref _array, null); - - if (array != null) - { - ArrayPool.Shared.Return(array); - } - } - } - } -} -- cgit v1.2.3