Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/mscorlib/shared/System/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ public bool TryGetArray(out ArraySegment<T> arraySegment)
return true;
}

if (_length == 0)
{
#if FEATURE_PORTABLE_SPAN
arraySegment = new ArraySegment<T>(SpanHelpers.PerTypeValues<T>.EmptyArray);
#else
arraySegment = ArraySegment<T>.Empty;
#endif // FEATURE_PORTABLE_SPAN
return true;
}

arraySegment = default(ArraySegment<T>);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public static bool TryGetArray<T>(ReadOnlyMemory<T> readOnlyMemory, out ArraySeg
return true;
}

if (length == 0)
{
#if FEATURE_PORTABLE_SPAN
arraySegment = new ArraySegment<T>(SpanHelpers.PerTypeValues<T>.EmptyArray);
#else
arraySegment = ArraySegment<T>.Empty;
#endif // FEATURE_PORTABLE_SPAN
return true;
}

arraySegment = default;
return false;
}
Expand Down