[webkit-changes] [WebKit/WebKit] c72763: Avoid calling scanTagName() in HTMLFastPathParser:...

Chris Dumez noreply at github.com
Mon Apr 3 11:43:20 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c727638623487a921b8bee06568220f69965db10
      https://github.com/WebKit/WebKit/commit/c727638623487a921b8bee06568220f69965db10
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-04-03 (Mon, 03 Apr 2023)

  Changed paths:
    M Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp
    M Source/WebCore/html/parser/ParsingUtilities.h

  Log Message:
  -----------
  Avoid calling scanTagName() in HTMLFastPathParser::parseContainerElement()
https://bugs.webkit.org/show_bug.cgi?id=254920

Reviewed by Ryosuke Niwa.

parseContainerElement() used to call scanTagName(), which would read all the
characters of the tag and convert them to lowercase. Then it would convert
the Span of characters to an ElementName enum.

However, in this case, we're parsing the end tag and we know it has to match
the start tag. If it doesn't then the element wouldn't be valid. As a result,
we can just call skipCharactersExactly() in the fast path, which will do a
simple memcmp() and succeed most of the time. In the slow case, we fall back
to calling skipLettersExactlyIgnoringASCIICase() in case the end tag is not
lowercase.

This is slightly more efficient.

* Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp:
(WebCore::HTMLFastPathParser::parseContainerElement):
* Source/WebCore/html/parser/ParsingUtilities.h:
(WebCore::skipLettersExactlyIgnoringASCIICase):
(WebCore::skipCharactersExactly): Deleted.

Canonical link: https://commits.webkit.org/262520@main




More information about the webkit-changes mailing list