Fix ArrayBuilder capacity expansion bug
This commit is contained in:
parent
ad2c63ca37
commit
7ad88a9406
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
|
||||||
{
|
{
|
||||||
if (_itemsInUse == _items.Length)
|
if (_itemsInUse == _items.Length)
|
||||||
{
|
{
|
||||||
SetCapacity(_itemsInUse * 2, preserveContents: true);
|
SetCapacity(_items.Length * 2, preserveContents: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexOfAppendedItem = _itemsInUse++;
|
var indexOfAppendedItem = _itemsInUse++;
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
|
||||||
var requiredCapacity = _itemsInUse + length;
|
var requiredCapacity = _itemsInUse + length;
|
||||||
if (_items.Length < requiredCapacity)
|
if (_items.Length < requiredCapacity)
|
||||||
{
|
{
|
||||||
var candidateCapacity = _itemsInUse * 2;
|
var candidateCapacity = _items.Length * 2;
|
||||||
while (candidateCapacity < requiredCapacity)
|
while (candidateCapacity < requiredCapacity)
|
||||||
{
|
{
|
||||||
candidateCapacity *= 2;
|
candidateCapacity *= 2;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue