mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Use Element::id() in getElementById()
This avoids the O(n) walk of element attributes, although there is still a huge space for improvement here if we start keeping a lookup cache for elements-by-ID.
This commit is contained in:
parent
e205f93cbb
commit
d0d7e5a782
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d0d7e5a782 Pull-request: https://github.com/SerenityOS/serenity/pull/21746 Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 2 additions and 2 deletions
|
@ -22,7 +22,7 @@ public:
|
|||
{
|
||||
JS::GCPtr<Element const> found_element;
|
||||
static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.id() == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
{
|
||||
JS::GCPtr<Element> found_element;
|
||||
static_cast<NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.id() == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue