Skip to content

Commit 15a13db

Browse files
committed
Simplified things a bit and got rid of commented out code
1 parent af56ac6 commit 15a13db

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

HtmlKit/HtmlTokenizer.cs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,6 @@ HtmlToken EmitTagToken ()
891891
// 8.2.4.1 Data state
892892
HtmlToken? ReadData ()
893893
{
894-
//ReadOnlySpan<char> specials = DecodeCharacterReferences ?
895-
// stackalloc char[] { '\n', '&', '<' } :
896-
// stackalloc char[] { '\n', '<' };
897-
898894
do {
899895
if (!TryRead (out char c)) {
900896
TokenizerState = HtmlTokenizerState.EndOfFile;
@@ -931,10 +927,6 @@ HtmlToken EmitTagToken ()
931927
// 8.2.4.3 RCDATA state
932928
HtmlToken? ReadRcData ()
933929
{
934-
//ReadOnlySpan<char> specials = DecodeCharacterReferences ?
935-
// stackalloc char[] { '\0', '\n', '&', '<' } :
936-
// stackalloc char[] { '\0', '\n', '<' };
937-
938930
do {
939931
if (!TryRead (out char c)) {
940932
TokenizerState = HtmlTokenizerState.EndOfFile;
@@ -970,8 +962,6 @@ HtmlToken EmitTagToken ()
970962
// 8.2.4.5 RAWTEXT state
971963
HtmlToken? ReadRawText ()
972964
{
973-
//ReadOnlySpan<char> specials = stackalloc char[] { '\0', '\n', '<' };
974-
975965
do {
976966
if (!TryRead (out char c)) {
977967
TokenizerState = HtmlTokenizerState.EndOfFile;
@@ -994,8 +984,6 @@ HtmlToken EmitTagToken ()
994984
// 8.2.4.6 Script data state
995985
HtmlToken? ReadScriptData ()
996986
{
997-
//ReadOnlySpan<char> specials = stackalloc char[] { '\0', '\n', '<' };
998-
999987
do {
1000988
if (!TryRead (out char c)) {
1001989
TokenizerState = HtmlTokenizerState.EndOfFile;
@@ -1015,22 +1003,17 @@ HtmlToken EmitTagToken ()
10151003
return EmitScriptDataToken ();
10161004
}
10171005

1018-
static readonly char[] PlainTextSpecials = new char[] { '\0', '\n' };
10191006
#if NET8_0_OR_GREATER
1020-
static readonly SearchValues<char> PlainTextSpecialsSV = SearchValues.Create (PlainTextSpecials);
1007+
static readonly SearchValues<char> PlainTextSpecials = SearchValues.Create (new char[] { '\0', '\n' });
1008+
#else
1009+
static readonly char[] PlainTextSpecials = new char[] { '\0', '\n' };
10211010
#endif
10221011

10231012
// 8.2.4.7 PLAINTEXT state
10241013
HtmlToken? ReadPlainText ()
10251014
{
1026-
#if NET8_0_OR_GREATER
1027-
SearchValues<char> specials = PlainTextSpecialsSV;
1028-
#else
1029-
ReadOnlySpan<char> specials = PlainTextSpecials;
1030-
#endif
1031-
10321015
do {
1033-
if (!TryReadDataUntil (specials, out char c)) {
1016+
if (!TryReadDataUntil (PlainTextSpecials, out char c)) {
10341017
TokenizerState = HtmlTokenizerState.EndOfFile;
10351018
break;
10361019
}
@@ -1115,8 +1098,6 @@ HtmlToken EmitTagToken ()
11151098
// 8.2.4.10 Tag name state
11161099
HtmlToken? ReadTagName ()
11171100
{
1118-
//ReadOnlySpan<char> specials = stackalloc char[] { '\0', '\t', '\r', '\n', '\f', ' ', '/', '>' };
1119-
11201101
do {
11211102
if (!TryRead (out char c)) {
11221103
TokenizerState = HtmlTokenizerState.EndOfFile;
@@ -1815,18 +1796,19 @@ HtmlToken EmitTagToken ()
18151796
} while (true);
18161797
}
18171798

1818-
static readonly char[] AttributeValueQuotedDQuoteSpecials = { '\0', '\n', '&', '\"' };
1819-
static readonly char[] AttributeValueQuotedSQuoteSpecials = { '\0', '\n', '&', '\'' };
18201799
#if NET8_0_OR_GREATER
1821-
static readonly SearchValues<char> AttributeValueQuotedDQuoteSpecialsSV = SearchValues.Create (AttributeValueQuotedDQuoteSpecials);
1822-
static readonly SearchValues<char> AttributeValueQuotedSQuoteSpecialsSV = SearchValues.Create (AttributeValueQuotedSQuoteSpecials);
1800+
static readonly SearchValues<char> AttributeValueQuotedDQuoteSpecials = SearchValues.Create (new char[] { '\0', '\n', '&', '\"' });
1801+
static readonly SearchValues<char> AttributeValueQuotedSQuoteSpecials = SearchValues.Create (new char[] { '\0', '\n', '&', '\'' });
1802+
#else
1803+
static readonly char[] AttributeValueQuotedDQuoteSpecials = new char[] { '\0', '\n', '&', '\"' };
1804+
static readonly char[] AttributeValueQuotedSQuoteSpecials = new char[] { '\0', '\n', '&', '\'' };
18231805
#endif
18241806

18251807
// 8.2.4.38 Attribute value (double-quoted) state
18261808
HtmlToken? ReadAttributeValueQuoted ()
18271809
{
18281810
#if NET8_0_OR_GREATER
1829-
SearchValues<char> specials = quote == '\"' ? AttributeValueQuotedDQuoteSpecialsSV : AttributeValueQuotedSQuoteSpecialsSV;
1811+
SearchValues<char> specials = quote == '\"' ? AttributeValueQuotedDQuoteSpecials : AttributeValueQuotedSQuoteSpecials;
18301812
#else
18311813
ReadOnlySpan<char> specials = quote == '\"' ? AttributeValueQuotedDQuoteSpecials : AttributeValueQuotedSQuoteSpecials;
18321814
#endif

0 commit comments

Comments
 (0)