Skip to content

Commit 53b84a0

Browse files
committed
Minor code tweaks
1 parent 8fe8c46 commit 53b84a0

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Microsoft.Toolkit.HighPerformance/Memory/Memory2D{T}.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,8 @@ public bool TryGetMemory(out Memory<T> memory)
786786
}
787787
else if (this.instance is MemoryManager<T> memoryManager)
788788
{
789-
unsafe
790-
{
791-
// If the object is a MemoryManager<T>, just slice it as needed
792-
memory = memoryManager.Memory.Slice((int)(void*)this.offset, this.height * this.width);
793-
}
789+
// If the object is a MemoryManager<T>, just slice it as needed
790+
memory = memoryManager.Memory.Slice((int)(nint)this.offset, this.height * this.width);
794791
}
795792
else if (this.instance.GetType() == typeof(T[]))
796793
{

Microsoft.Toolkit.HighPerformance/Memory/ReadOnlyMemory2D{T}.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,8 @@ public bool TryGetMemory(out ReadOnlyMemory<T> memory)
802802
}
803803
else if (this.instance is MemoryManager<T> memoryManager)
804804
{
805-
unsafe
806-
{
807-
// If the object is a MemoryManager<T>, just slice it as needed
808-
memory = memoryManager.Memory.Slice((int)(void*)this.offset, this.height * this.width);
809-
}
805+
// If the object is a MemoryManager<T>, just slice it as needed
806+
memory = memoryManager.Memory.Slice((int)(nint)this.offset, this.height * this.width);
810807
}
811808
else if (this.instance.GetType() == typeof(T[]))
812809
{

0 commit comments

Comments
 (0)