Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

MemoryPoolIterator2.Seek performance #514

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public abstract partial class Frame : FrameContext, IFrameControl
private static readonly byte[] _bytesDate = Encoding.ASCII.GetBytes("Date: ");
private static readonly byte[] _bytesEndHeaders = Encoding.ASCII.GetBytes("\r\n\r\n");

private static readonly Vector<byte> _vectorCRs = new Vector<byte>((byte)'\r');
private static readonly Vector<byte> _vectorColons = new Vector<byte>((byte)':');
private static readonly Vector<byte> _vectorSpaces = new Vector<byte>((byte)' ');
private static readonly Vector<byte> _vectorQuestionMarks = new Vector<byte>((byte)'?');
private static readonly Vector<byte> _vectorPercentages = new Vector<byte>((byte)'%');
private static Vector<byte> _vectorCRs = new Vector<byte>((byte)'\r');
private static Vector<byte> _vectorColons = new Vector<byte>((byte)':');
private static Vector<byte> _vectorSpaces = new Vector<byte>((byte)' ');
private static Vector<byte> _vectorQuestionMarks = new Vector<byte>((byte)'?');
private static Vector<byte> _vectorPercentages = new Vector<byte>((byte)'%');

private readonly object _onStartingSync = new Object();
private readonly object _onCompletedSync = new Object();
Expand Down Expand Up @@ -711,7 +711,7 @@ protected bool TakeStartLine(SocketInput input)
try
{
var begin = scan;
if (scan.Seek(_vectorSpaces) == -1)
if (scan.Seek(ref _vectorSpaces) == -1)
{
return false;
}
Expand All @@ -726,11 +726,11 @@ protected bool TakeStartLine(SocketInput input)
begin = scan;

var needDecode = false;
var chFound = scan.Seek(_vectorSpaces, _vectorQuestionMarks, _vectorPercentages);
var chFound = scan.Seek(ref _vectorSpaces, ref _vectorQuestionMarks, ref _vectorPercentages);
if (chFound == '%')
{
needDecode = true;
chFound = scan.Seek(_vectorSpaces, _vectorQuestionMarks);
chFound = scan.Seek(ref _vectorSpaces, ref _vectorQuestionMarks);
}

var pathBegin = begin;
Expand All @@ -740,7 +740,7 @@ protected bool TakeStartLine(SocketInput input)
if (chFound == '?')
{
begin = scan;
if (scan.Seek(_vectorSpaces) != ' ')
if (scan.Seek(ref _vectorSpaces) != ' ')
{
return false;
}
Expand All @@ -749,7 +749,7 @@ protected bool TakeStartLine(SocketInput input)

scan.Take();
begin = scan;
if (scan.Seek(_vectorCRs) == -1)
if (scan.Seek(ref _vectorCRs) == -1)
{
return false;
}
Expand Down Expand Up @@ -843,7 +843,7 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
while (!scan.IsEnd)
{
var beginName = scan;
scan.Seek(_vectorColons, _vectorCRs);
scan.Seek(ref _vectorColons, ref _vectorCRs);
var endName = scan;

chFirst = scan.Take();
Expand Down Expand Up @@ -894,7 +894,7 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
var wrapping = false;
while (!scan.IsEnd)
{
if (scan.Seek(_vectorCRs) == -1)
if (scan.Seek(ref _vectorCRs) == -1)
{
// no "\r" in sight, burn used bytes and go back to await more data
return false;
Expand Down
Loading