Handle comments correctly

This commit is contained in:
Wilson Lin 2020-01-19 11:44:11 +11:00
parent 9f93a5d6de
commit 6b2b8cf552
7 changed files with 59 additions and 59 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -5,8 +5,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 353540,
"relative": 0.9585809726259165
"absolute": 353498,
"relative": 0.9584670947030498
},
"html-minifier": {
"absolute": 355185,
@ -23,8 +23,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 231718,
"relative": 0.9411129207162787
"absolute": 231702,
"relative": 0.9410479373885637
},
"html-minifier": {
"absolute": 234306,
@ -59,8 +59,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 270869,
"relative": 0.8744987764010047
"absolute": 270827,
"relative": 0.8743631796785712
},
"html-minifier": {
"absolute": 277911,
@ -77,8 +77,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 79807,
"relative": 0.9430330387105922
"absolute": 79804,
"relative": 0.9429975894503001
},
"html-minifier": {
"absolute": 81446,
@ -95,8 +95,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 5744290,
"relative": 0.9094262560459782
"absolute": 5744286,
"relative": 0.9094256227727583
},
"html-minifier": {
"absolute": 5785725,
@ -203,8 +203,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 272478,
"relative": 0.8645868369114782
"absolute": 272477,
"relative": 0.8645836638595734
},
"html-minifier": {
"absolute": 266639,
@ -221,8 +221,8 @@
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 1319434,
"relative": 0.9350028877054611
"absolute": 1319430,
"relative": 0.9350000531479533
},
"html-minifier": {
"absolute": 1327244,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -1,67 +1,67 @@
{
"Amazon": {
"hyperbuild-nodejs": 502.24664208689205,
"html-minifier": 35.29094514423333,
"minimize": 115.65576358024069
"hyperbuild-nodejs": 497.0684008679241,
"html-minifier": 36.28930820880813,
"minimize": 114.18558697357896
},
"BBC": {
"hyperbuild-nodejs": 534.2273806686738,
"html-minifier": 48.494203597533264,
"minimize": 162.19058006327936
"hyperbuild-nodejs": 530.356838970197,
"html-minifier": 48.63263590575628,
"minimize": 160.9462295874063
},
"Bing": {
"hyperbuild-nodejs": 2140.7640403400474,
"html-minifier": 219.51796458703646,
"minimize": 556.4985790478128
"hyperbuild-nodejs": 2134.6747025695076,
"html-minifier": 221.00143110816123,
"minimize": 551.4842672816046
},
"Bootstrap": {
"hyperbuild-nodejs": 281.194875239674,
"html-minifier": 7.8415099622038555,
"minimize": 22.529031134122878
"hyperbuild-nodejs": 271.35337683063364,
"html-minifier": 7.97192942546144,
"minimize": 22.302011949055192
},
"Coding Horror": {
"hyperbuild-nodejs": 1047.0958113343395,
"html-minifier": 47.42413048467408,
"minimize": 192.42462057036215
"hyperbuild-nodejs": 1019.5233646175254,
"html-minifier": 49.28536290527941,
"minimize": 187.54666897520576
},
"ECMA-262": {
"hyperbuild-nodejs": 15.772555656834477,
"html-minifier": 0.44192845474704334,
"minimize": 1.3294991658715587
"hyperbuild-nodejs": 15.344258383194457,
"html-minifier": 0.44536511869011475,
"minimize": 1.3342793943531839
},
"Google": {
"hyperbuild-nodejs": 1835.2139045218082,
"html-minifier": 241.2525641836837,
"minimize": 580.9205037326506
"hyperbuild-nodejs": 1827.5416680815183,
"html-minifier": 242.58427545496446,
"minimize": 579.275465488081
},
"Hacker News": {
"hyperbuild-nodejs": 2078.0864684534695,
"html-minifier": 73.73992684219166,
"minimize": 275.23770113550273
"hyperbuild-nodejs": 2071.747702993173,
"html-minifier": 73.41021778919102,
"minimize": 270.4509347009959
},
"NY Times": {
"hyperbuild-nodejs": 262.6791315524891,
"html-minifier": 37.21473163759241,
"minimize": 87.5459988860411
"hyperbuild-nodejs": 276.16242726823117,
"html-minifier": 36.853296596407354,
"minimize": 86.40323822747456
},
"Reddit": {
"hyperbuild-nodejs": 392.33718670985326,
"html-minifier": 45.080090941207395,
"minimize": 126.02956065880237
"hyperbuild-nodejs": 404.3269179058215,
"html-minifier": 44.98344851074736,
"minimize": 124.11335556541236
},
"Stack Overflow": {
"hyperbuild-nodejs": 806.413713289417,
"html-minifier": 41.36174599511134,
"minimize": 161.42178263684914
"hyperbuild-nodejs": 820.8141564896657,
"html-minifier": 41.63919304297733,
"minimize": 161.27817560216315
},
"Twitter": {
"hyperbuild-nodejs": 277.80868572702855,
"html-minifier": 37.062907987061436,
"minimize": 168.569458535333
"hyperbuild-nodejs": 280.20971195021036,
"html-minifier": 37.298870434334766,
"minimize": 166.8418036944524
},
"Wikipedia": {
"hyperbuild-nodejs": 54.76838615471663,
"html-minifier": 2.7997721992329714,
"minimize": 8.79398557057751
"hyperbuild-nodejs": 54.272192449450806,
"html-minifier": 2.8349496354931727,
"minimize": 8.748906528012489
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -67,6 +67,11 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
// Do not write anything until any previously ignored whitespace has been processed later.
let next_content_type = ContentType::peek(proc);
let entity: Option<EntityType> = match next_content_type {
ContentType::Comment => {
// Comments are completely ignored and do not affect anything (previous element node's closing tag, unintentional entities, whitespace, etc.).
process_comment(proc)?;
continue;
}
ContentType::Entity => Some(parse_entity(proc, false)?),
_ => None,
};
@ -108,11 +113,6 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
// Process and consume next character(s).
match next_content_type {
ContentType::Comment => {
// Comments are completely ignored and do not affect anything (previous element node's closing tag, unintentional entities, whitespace, etc.).
process_comment(proc)?;
continue;
}
ContentType::Tag => {
proc.suspend(uep);
let new_closing_tag = process_tag(
@ -177,7 +177,7 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
}
};
// This should not be reached if ContentType::Comment.
// This should not be reached if ContentType::{Comment, End}.
last_written = next_content_type;
};