Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 414b33a529b81d04b3537667850a9799ba9fb03a
      
https://github.com/WebKit/WebKit/commit/414b33a529b81d04b3537667850a9799ba9fb03a
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-05 (Sun, 05 Apr 2026)

  Changed paths:
    M Source/WebCore/html/parser/HTMLTreeBuilder.cpp

  Log Message:
  -----------
  Short-circuit isParsingTemplateContents() with O(1) containsTemplateElement() 
check
https://bugs.webkit.org/show_bug.cgi?id=311512

Reviewed by Anne van Kesteren.

isParsingTemplateContents() calls hasTemplateInHTMLScope(), which walks the
entire open elements stack via inScopeCommon(). In the common case where no
<template> element exists, this is a wasted linear scan all the way to the root.

HTMLElementStack already maintains an O(1) counter via 
containsTemplateElement().
Add it as an early-out before the scope walk so the common no-template case
returns immediately.

* Source/WebCore/html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::isParsingTemplateContents const):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to