Browse Source

Reduce the performance cost of Memory<T>.getSpan()

release/3.x.x
xljiulang 4 years ago
parent
commit
9ed80daf83
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs

+ 2
- 2
Source/MQTTnet.AspnetCore/Extensions/ReaderExtensions.cs View File

@@ -80,7 +80,7 @@ namespace MQTTnet.AspNetCore
headerLength = 0; headerLength = 0;
bodyLength = 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 do
{ {
@@ -88,7 +88,7 @@ namespace MQTTnet.AspNetCore
{ {
return false; return false;
} }
encodedByte = temp.Span[index];
encodedByte = temp[index];
index++; index++;


value += (byte)(encodedByte & 127) * multiplier; value += (byte)(encodedByte & 127) * multiplier;


Loading…
Cancel
Save