Skip to content
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
15 changes: 12 additions & 3 deletions tools/SendBlobs/BlobSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,18 @@ public async Task SendData(
bool waitForInclusion,
IReleaseSpec spec)
{
data = data
.Select((s, i) => i % 32 != 0 ? [s] : (s < 0x73 ? new byte[] { s } : [(byte)(32), s]))
.SelectMany(b => b).ToArray();
int capacity = data.Length + data.Length / 32; // at most one extra byte per 32-byte chunk
List<byte> normalized = new(capacity);
for (int i = 0; i < data.Length; i++)
{
byte value = data[i];
if (i % 32 == 0 && value >= 0x73)
{
normalized.Add(32);
}
normalized.Add(value);
}
data = normalized.ToArray();
Comment on lines +208 to +218
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could do 2 scans, one to calculate length and the other to do actual normalization. This way we could just allocate array and avoid allocating list.

But this is just BlobSender, so probably performance and GC pressure are not that crucial


if (waitForInclusion)
{
Expand Down