Skip to content

Commit

Permalink
Refs #18687. Improve calculation of maxSerializedSize in containers
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Sep 15, 2023
1 parent e52604b commit 27e905a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ public long maxSerializedSize(
size *= Long.parseLong(getDimensions().get(count), 10);
}

for (long count = 0; count < size; ++count)
if (0 < size)
{
current_alignment += ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);

if (1 < size)
{
long element_size_after_first = ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);
current_alignment += element_size_after_first * (size - 1);
}
}

return current_alignment - initial_alignment;
Expand All @@ -60,9 +66,17 @@ public long maxPlainTypeSerializedSize(
size *= Long.parseLong(getDimensions().get(count), 10);
}

for (long count = 0; count < size; ++count)
if (0 < size)
{
current_alignment += ((TypeCode)getContentTypeCode()).maxPlainTypeSerializedSize(current_alignment, align64);
current_alignment += ((TypeCode)getContentTypeCode()).maxPlainTypeSerializedSize(
current_alignment, align64);

if (1 < size)
{
long element_size_after_first = ((TypeCode)getContentTypeCode()).maxPlainTypeSerializedSize(
current_alignment, align64);
current_alignment += element_size_after_first * (size - 1);
}
}

return current_alignment - initial_alignment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ public long maxSerializedSize(

current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4);

for (long count = 0; count < maxsize; ++count)
if (0 < maxsize)
{
current_alignment += ((TypeCode)getKeyTypeCode()).maxSerializedSize(current_alignment);
current_alignment += ((TypeCode)getValueTypeCode()).maxSerializedSize(current_alignment);

if (1 < maxsize)
{
long element_size_after_first = ((TypeCode)getKeyTypeCode()).maxSerializedSize(current_alignment);
element_size_after_first += ((TypeCode)getValueTypeCode()).maxSerializedSize(
current_alignment + element_size_after_first);
current_alignment += element_size_after_first * (maxsize - 1);
}
}

return current_alignment - initial_alignment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ public long maxSerializedSize(

current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4);

for (long count = 0; count < maxsize; ++count)
if (0 < maxsize)
{
current_alignment += ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);

if (1 < maxsize)
{
long element_size_after_first = ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);
current_alignment += element_size_after_first * (maxsize - 1);
}
}

if (should_set_and_unset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ public long maxSerializedSize(

current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4);

for (long count = 0; count < maxsize; ++count)
if (0 < maxsize)
{
current_alignment += ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);

if (1 < maxsize)
{
long element_size_after_first = ((TypeCode)getContentTypeCode()).maxSerializedSize(current_alignment);
current_alignment += element_size_after_first * (maxsize - 1);
}
}

return current_alignment - initial_alignment;
Expand Down

0 comments on commit 27e905a

Please sign in to comment.