Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c2595e7

Browse files
committed
coreclr Feedback
1 parent e23f99f commit c2595e7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Common/src/CoreLib/System/Runtime/InteropServices/MemoryMarshal.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public static bool TryGetArray<T>(ReadOnlyMemory<T> readOnlyMemory, out ArraySeg
4646
public static bool TryGetOwnedMemory<T, TOwner>(ReadOnlyMemory<T> readOnlyMemory, out TOwner ownedMemory)
4747
where TOwner : OwnedMemory<T>
4848
{
49-
ownedMemory = readOnlyMemory._object as TOwner;
50-
return !ReferenceEquals(ownedMemory, null);
49+
TOwner owner; // Use register for null comparision rahter than byref
50+
ownedMemory = owner = readOnlyMemory._object as TOwner;
51+
return !ReferenceEquals(owner, null);
5152
}
5253

5354
/// <summary>
@@ -57,8 +58,9 @@ public static bool TryGetOwnedMemory<T, TOwner>(ReadOnlyMemory<T> readOnlyMemory
5758
public static bool TryGetOwnedMemory<T, TOwner>(ReadOnlyMemory<T> readOnlyMemory, out TOwner ownedMemory, out int index, out int length)
5859
where TOwner : OwnedMemory<T>
5960
{
60-
ownedMemory = readOnlyMemory._object as TOwner;
61-
if (!ReferenceEquals(ownedMemory, null))
61+
TOwner owner; // Use register for null comparision rahter than byref
62+
ownedMemory = owner = readOnlyMemory._object as TOwner;
63+
if (!ReferenceEquals(owner, null))
6264
{
6365
index = _index;
6466
length = _length;

0 commit comments

Comments
 (0)