Skip to content

Commit

Permalink
Simplify MoveToFlatArray model
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Aug 16, 2023
1 parent d83be64 commit 9b34f24
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ partial struct FlatArray<T>
partial class Builder
{
public FlatArray<T> MoveToFlatArray()
=>
InnerMoveToFlatArray(false);

// TODO: Add the tests and make public
internal FlatArray<T> MoveToFlatArray(bool trimExcess)
=>
InnerMoveToFlatArray(trimExcess);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private FlatArray<T> InnerMoveToFlatArray(bool trimExcess)
{
var length = this.length;
var items = this.items;
Expand All @@ -29,7 +19,7 @@ private FlatArray<T> InnerMoveToFlatArray(bool trimExcess)
return default;
}

if (trimExcess && length != items.Length || InnerAllocHelper.IsHugeCapacity(length, items.Length))
if (InnerAllocHelper.IsHugeCapacity(length, items.Length))
{
Array.Resize(ref items, length);
}
Expand Down

0 comments on commit 9b34f24

Please sign in to comment.