Uh oh!
There was an error while loading. Please reload this page.
[CBOR] Implement indefinite length writer and reader support - #33831
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // performing validation and returning a list of ranges containing the individual chunk payloads | ||
| private List<(int offset, int length)> ReadChunkedStringRanges(CborMajorType type, out int encodingLength, out int concatenatedBufferSize) | ||
| { | ||
| var ranges = new List<(int offset, int length)>(); |
There was a problem hiding this comment.
I don't know if it's worth the complexity; but you could do something like
List<(intoffset,intlength)>ranges=Interlocked.Exchange(ref_ranges,null);ranges??=newList<(int,int)>();ranges.Clear();And have all of the calling members assign it back to the field right before returning.
It's not super important, though.
There was a problem hiding this comment.
I'll give it a shot, provided it doesn't make things too hard to read. Or maybe wait until benchmarking demonstrates issues with allocations.
Also, why Interlocked? The class offers no thread safety guarantees.
There was a problem hiding this comment.
It's both a quick way of "I've taken this" (in case somehow this ever went recursive, which I know isn't currently possible) and it means that the kinds of scary race conditions are limited. (overlapping writes from a read method is scarier to me than read twice or read slightly forward)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Adds indefinite length writer and reader support for strings, maps and arrays: