Skip to content
Discussion options

You must be logged in to vote

What? No.

You don't need the class (since the slice would already be length-limited), and whatever WriteAsync(...) is should be taking ReadOnlyMemory<byte> which you can get directly from (iterating through) the sequence, so there's no reason to get an array copy of the data either.

Also, in some cases sending an array to another method is supposed to relinquish ownership of it, so it may not be safe to return the array after passing it to another method.

That said:

  1. If all you're doing is writing the bytes somewhere, you'd just pass the stream through, or use CopyToAsync(...), and not bother with anything at this point in the pipeline. Using pipes is mostly meant for de/serializing, and …

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@Vincent-X-Zhang
Comment options

@Clockwork-Muse
Comment options

@Vincent-X-Zhang
Comment options

@Clockwork-Muse
Comment options

Answer selected by Vincent-X-Zhang
@Vincent-X-Zhang
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants