in src/Proton.TestPeer/Codec/Impl/ListElement.cs [168:225]
private uint ComputeSize()
{
uint count = 0;
uint size = 0;
IElement elt = first;
while (elt != null)
{
count++;
size += elt.GetSize();
elt = elt.Next;
}
if (IsElementOfArray())
{
ArrayElement parent = (ArrayElement)Parent;
if (parent.ConstructorType == ConstructorType.Tiny)
{
if (count != 0)
{
parent.ConstructorType = ConstructorType.Small;
size += 2;
}
}
else if (parent.ConstructorType == ConstructorType.Small)
{
if (count > 255 || size > 254)
{
parent.ConstructorType = ConstructorType.Large;
size += 8;
}
else
{
size += 2;
}
}
else
{
size += 8;
}
}
else
{
if (count == 0)
{
size = 1;
}
else if (count <= 255 && size <= 254)
{
size += 3;
}
else
{
size += 9;
}
}
return size;
}