1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 21:34:11 +02:00

Merge pull request #1082 from disarray2077/null_array_span

Allow Spans to be created from null Arrays
This commit is contained in:
Brian Fiete 2021-06-25 06:05:57 -07:00 committed by GitHub
commit b66f13849f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,18 +16,35 @@ namespace System
public this(T[] array) public this(T[] array)
{ {
if (array == null)
{
this = default;
return;
}
mPtr = &array.[Friend]GetRef(0); mPtr = &array.[Friend]GetRef(0);
mLength = array.[Friend]mLength; mLength = array.[Friend]mLength;
} }
public this(T[] array, int index) public this(T[] array, int index)
{ {
if (array == null)
{
Debug.Assert(index == 0);
this = default;
return;
}
mPtr = &array[index]; mPtr = &array[index];
mLength = array.[Friend]mLength - index; mLength = array.[Friend]mLength - index;
} }
public this(T[] array, int index, int length) public this(T[] array, int index, int length)
{ {
if (array == null)
{
Debug.Assert(index == 0 && length == 0);
this = default;
return;
}
if (length == 0) if (length == 0)
mPtr = null; mPtr = null;
else else