Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
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: 5 additions & 5 deletions src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace System.Collections.Generic
internal struct LargeArrayBuilder<T>
{
private const int StartingCapacity = 4;
private const int ResizeLimit = 32;
private const int ResizeLimit = 8;

private readonly int _maxCapacity; // The maximum capacity this builder can have.
private T[] _first; // The first buffer we store items in. Resized until ResizeLimit.
Expand Down Expand Up @@ -210,11 +210,11 @@ private void AllocateBuffer()
}
else
{
// Example scenario: Let's say _count == 256.
// Then our buffers look like this: | 32 | 32 | 64 | 128 |
// Example scenario: Let's say _count == 64.
// Then our buffers look like this: | 8 | 8 | 16 | 32 |
// As you can see, our count will be just double the last buffer.
// Now, say _maxCapacity is 500. We will find the right amount to allocate by
// doing min(256, 500 - 256). The lhs represents double the last buffer,
// Now, say _maxCapacity is 100. We will find the right amount to allocate by
// doing min(64, 100 - 64). The lhs represents double the last buffer,
// the rhs the limit minus the amount we've already allocated.

Debug.Assert(_count >= ResizeLimit * 2);
Expand Down