Allocation-free version of Receive
Closed this issue · 1 comments
hey joel,
would you accept a breaking PR that makes the Receive for both client and server allocation-free?
example on the client:
here the internal function is returning an ArraySegment of which currently two copies are made: first into a MemoryStream, then into the buffer (which is also currently allocated twice: L607 and L614). returning the ArraySegment directly therefore get rid of two allocations.
i'm afraid this would be a minor breaking change, since the MessageReceivedEventArgs will need to have ArraySegment of byte instead of byte[] for data. would you still be accepting this? (if so, i'd PR the same for SuperSimpleTCP then which has the same issue)
Hi @joreg I agree it's the right thing to do, because it aligns the input structures with the underlying implementation. I would love a PR on these (happily on any library I manage) and will just increment the major version number (and of course add you to the README as a contributor!). Cheers, Joel