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 @@ -103,11 +103,19 @@ public override unsafe int FindFirstCharacterToEncode(char* text, int textLength
#endif
Debug.Assert(textLength > 0 && ptr < end);

// For performance on the Mono interpreter, avoid referencing the static table for every value.
ReadOnlySpan<byte> allowListLocal = AllowList;

do
{
Debug.Assert(text <= ptr && ptr < (text + textLength));

if (NeedsEscaping(*(char*)ptr))
char value = *(char*)ptr;

// NeedsEscaping() is lifted below for perf; verify semantics remain consistent.
Debug.Assert((value > LastAsciiCharacter || allowListLocal[value] == 0) == NeedsEscaping(value));

if (value > LastAsciiCharacter || allowListLocal[value] == 0)
{
goto Return;
}
Expand Down Expand Up @@ -276,11 +284,17 @@ public override unsafe int FindFirstCharacterToEncodeUtf8(ReadOnlySpan<byte> utf
#endif
Debug.Assert(textLength > 0 && ptr < end);

// For performance on the Mono interpreter, avoid referencing the static table for every value.
ReadOnlySpan<byte> allowListLocal = AllowList;

do
{
Debug.Assert(pValue <= ptr && ptr < (pValue + utf8Text.Length));

if (NeedsEscaping(*ptr))
// NeedsEscaping() is lifted below for perf; verify semantics remain consistent.
Debug.Assert((allowListLocal[*ptr] == 0) == NeedsEscaping(*ptr));

if (allowListLocal[*ptr] == 0)
{
goto Return;
}
Expand Down