Skip to content

Commit

Permalink
FlatArray: Add constructor from Span
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Aug 24, 2023
1 parent 6852012 commit 2da1ed9
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public FlatArray([AllowNull] params T[] source)
items = InnerArrayHelper.Copy(source);
}


// TODO: Add the tests and make public
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal FlatArray(ReadOnlySpan<T> source)
Expand All @@ -32,4 +31,18 @@ internal FlatArray(ReadOnlySpan<T> source)
length = source.Length;
items = source.ToArray();
}

// TODO: Add the tests and make public
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal FlatArray(Span<T> source)
{
if (source.IsEmpty)
{
this = default;
return;
}

length = source.Length;
items = source.ToArray();
}
}

0 comments on commit 2da1ed9

Please sign in to comment.