-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We should cache the first base element in Document
https://bugs.webkit.org/show_bug.cgi?id=264113 rdar://117871556 Reviewed by Ryosuke Niwa. Sometimes, we consume much time for document.querySelector("base"), because this document ends up not having `base`. It means that it is traversing all the tree. But this traversal is already paid cost when we call Document::processBaseElement, which is called everytime `base` element is inserted or removed into the document to update baseURL. So we should just cache the first element here, and use this information in querySelector and querySelectorAll. This patch adds Document::firstBaseElement and adding a fast path for querySelector and querySelectorAll. querySelector uses this element directly. And querySelectorAll stops traversal when this firstBaseElement is nullptr. * Source/WebCore/dom/Document.cpp: (WebCore::Document::firstBaseElement const): (WebCore::Document::processBaseElement): * Source/WebCore/dom/Document.h: * Source/WebCore/dom/SelectorQuery.cpp: (WebCore::elementsForLocalName): Canonical link: https://commits.webkit.org/270150@main
- Loading branch information
1 parent
f1ab7fe
commit 6a6005d
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters