-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
Currently, CborWriter increases its buffer 1024 bytes at a time:
runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs
Lines 210 to 212 in 5149896
| 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.