Use the array unpacker instead of the Stream unpacker (#1619)

- This reduces allocations and improves throughout of msgpack
This commit is contained in:
David Fowler 2018-03-16 09:41:34 -07:00 committed by GitHub
parent b0e5483a5c
commit 227c6b8133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -41,16 +41,13 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
{
while (BinaryMessageParser.TryParseMessage(ref input, out var payload))
{
using (var memoryStream = new MemoryStream(payload.ToArray()))
{
messages.Add(ParseMessage(memoryStream, binder));
}
messages.Add(ParseMessage(payload.ToArray(), binder));
}
return messages.Count > 0;
}
private static HubMessage ParseMessage(Stream input, IInvocationBinder binder)
private static HubMessage ParseMessage(byte[] input, IInvocationBinder binder)
{
using (var unpacker = Unpacker.Create(input))
{