Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,44 +209,27 @@ private char Forwardcharnext(ReadOnlySpan<char> inputSpan)

private bool MatchString(string str, ReadOnlySpan<char> inputSpan)
{
int c = str.Length;
int pos;

if (!_rightToLeft)
{
if (inputSpan.Length - runtextpos < c)
if (runtextpos > inputSpan.Length ||
!inputSpan.Slice(runtextpos).StartsWith(str.AsSpan()))
{
return false;
}

pos = runtextpos + c;
runtextpos += str.Length;
return true;
}
else
{
if (runtextpos < c)
if (!inputSpan.Slice(0, runtextpos).EndsWith(str.AsSpan()))
{
return false;
}

pos = runtextpos;
}

while (c != 0)
{
if (str[--c] != inputSpan[--pos])
{
return false;
}
runtextpos -= str.Length;
return true;
}

if (!_rightToLeft)
{
pos += str.Length;
}

runtextpos = pos;

return true;
}

private bool MatchRef(int index, int length, ReadOnlySpan<char> inputSpan, bool caseInsensitive)
Expand Down
Loading