aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Common/Utilities/StreamUtils.cs
diff options
context:
space:
mode:
authorjhorv <38920027+jhorv@users.noreply.github.com>2024-08-05 20:09:08 -0400
committerGitHub <noreply@github.com>2024-08-05 21:09:08 -0300
commit7969fb6bbaf49a7a84df379d072b94286e4f7ada (patch)
treec5fdb45a7929601e217fb180f2678c449e3dc23b /src/Ryujinx.Common/Utilities/StreamUtils.cs
parent4a4b11871e362016b41c56d4dd4654ade0b894e0 (diff)
Replace and remove obsolete ByteMemoryPool type (#7155)
* refactor: replace usage of ByteMemoryPool with MemoryOwner<byte> * refactor: delete unused ByteMemoryPool and ByteMemoryPool.ByteMemoryPoolBuffer types * refactor: change IMemoryOwner<byte> return types to MemoryOwner<byte> * fix(perf): get span via `MemoryOwner<T>.Span` directly instead of `MemoryOwner<T>.Memory.Span` * fix(perf): get span via MemoryOwner<T>.Span directly instead of `MemoryOwner<T>.Memory.Span` * fix(perf): get span via MemoryOwner<T>.Span directly instead of `MemoryOwner<T>.Memory.Span`
Diffstat (limited to 'src/Ryujinx.Common/Utilities/StreamUtils.cs')
-rw-r--r--src/Ryujinx.Common/Utilities/StreamUtils.cs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Ryujinx.Common/Utilities/StreamUtils.cs b/src/Ryujinx.Common/Utilities/StreamUtils.cs
index 74b6af5e..aeb6e0d5 100644
--- a/src/Ryujinx.Common/Utilities/StreamUtils.cs
+++ b/src/Ryujinx.Common/Utilities/StreamUtils.cs
@@ -1,6 +1,5 @@
using Microsoft.IO;
using Ryujinx.Common.Memory;
-using System.Buffers;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -16,7 +15,7 @@ namespace Ryujinx.Common.Utilities
return output.ToArray();
}
- public static IMemoryOwner<byte> StreamToRentedMemory(Stream input)
+ public static MemoryOwner<byte> StreamToRentedMemory(Stream input)
{
if (input is MemoryStream inputMemoryStream)
{
@@ -26,9 +25,9 @@ namespace Ryujinx.Common.Utilities
{
long bytesExpected = input.Length;
- IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(bytesExpected);
+ MemoryOwner<byte> ownedMemory = MemoryOwner<byte>.Rent(checked((int)bytesExpected));
- var destSpan = ownedMemory.Memory.Span;
+ var destSpan = ownedMemory.Span;
int totalBytesRead = 0;
@@ -66,14 +65,14 @@ namespace Ryujinx.Common.Utilities
return stream.ToArray();
}
- private static IMemoryOwner<byte> MemoryStreamToRentedMemory(MemoryStream input)
+ private static MemoryOwner<byte> MemoryStreamToRentedMemory(MemoryStream input)
{
input.Position = 0;
- IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(input.Length);
+ MemoryOwner<byte> ownedMemory = MemoryOwner<byte>.Rent(checked((int)input.Length));
// Discard the return value because we assume reading a MemoryStream always succeeds completely.
- _ = input.Read(ownedMemory.Memory.Span);
+ _ = input.Read(ownedMemory.Span);
return ownedMemory;
}