From 9ed80daf83f03634804ab57705c635d4461ebf4f Mon Sep 17 00:00:00 2001 From: xljiulang <366193849@qq.com> Date: Wed, 25 Mar 2020 21:32:43 +0800 Subject: [PATCH] Reduce the performance cost of Memory.getSpan() --- Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs b/Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs index 2746c7d..d6ec584 100644 --- a/Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs +++ b/Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs @@ -80,7 +80,7 @@ namespace MQTTnet.AspNetCore headerLength = 0; bodyLength = 0; - var temp = input.Slice(0, Math.Min(5, input.Length)).GetMemory(); + var temp = input.Slice(0, Math.Min(5, input.Length)).GetMemory().Span; do { @@ -88,7 +88,7 @@ namespace MQTTnet.AspNetCore { return false; } - encodedByte = temp.Span[index]; + encodedByte = temp[index]; index++; value += (byte)(encodedByte & 127) * multiplier;