KEMBAR78
CborWriter should use doubling for buffer growth · Issue #92425 · dotnet/runtime · GitHub
Skip to content

CborWriter should use doubling for buffer growth #92425

@vcsjones

Description

@vcsjones

Currently, CborWriter increases its buffer 1024 bytes at a time:

const int BlockSize = 1024;
int blocks = checked(_offset + pendingCount + (BlockSize - 1)) / BlockSize;
Array.Resize(ref _buffer, BlockSize * blocks);

For large CBOR documents, this can be result in a lot of array resizing. We should instead change the strategy to do doubling.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions