Skip to content

Commit 4c337c8

Browse files
committed
Simplify the doctype matching
- the doctype() function is only called for a D or d token, so there is no need to check again inside the method - checking that we have the DOCTYPE string can use a sequence matching
1 parent 7b339b5 commit 4c337c8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/HTML5/Parser/Tokenizer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,12 +721,11 @@ protected function isCommentEnd()
721721
*/
722722
protected function doctype()
723723
{
724-
if (strcasecmp($this->scanner->current(), 'D')) {
725-
return false;
726-
}
727724
// Check that string is DOCTYPE.
728-
$chars = $this->scanner->charsWhile('DOCTYPEdoctype');
729-
if (strcasecmp($chars, 'DOCTYPE')) {
725+
if ($this->scanner->sequenceMatches('DOCTYPE', false)) {
726+
$this->scanner->consume(7);
727+
} else {
728+
$chars = $this->scanner->charsWhile('DOCTYPEdoctype');
730729
$this->parseError('Expected DOCTYPE, got %s', $chars);
731730

732731
return $this->bogusComment('<!' . $chars);

0 commit comments

Comments
 (0)