Skip to content

Commit

Permalink
Use SyntaxFacts.IsHexDigit instead of custom hex digit validator in…
Browse files Browse the repository at this point in the history
… lexer (#68016)
  • Loading branch information
jhinder authored May 10, 2023
1 parent f47ff93 commit 7eeb7ce
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/Compilers/CSharp/Portable/Parser/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,7 @@ private bool ScanIdentifier_SlowPath(ref TokenInfo info)
Debug.Assert(string.Equals(info.Text.Substring(0, objectAddressOffset + 1), "@0x", StringComparison.OrdinalIgnoreCase));
var valueText = TextWindow.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
// Verify valid hex value.
if ((valueText.Length == 0) || !valueText.All(IsValidHexDigit))
if ((valueText.Length == 0) || !valueText.All(SyntaxFacts.IsHexDigit))
{
goto Fail;
}
Expand All @@ -1955,16 +1955,6 @@ private bool ScanIdentifier_SlowPath(ref TokenInfo info)
return false;
}

private static bool IsValidHexDigit(char c)
{
if ((c >= '0') && (c <= '9'))
{
return true;
}
c = char.ToLower(c);
return (c >= 'a') && (c <= 'f');
}

/// <summary>
/// This method is essentially the same as ScanIdentifier_SlowPath,
/// except that it can handle XML entities. Since ScanIdentifier
Expand Down

0 comments on commit 7eeb7ce

Please sign in to comment.