mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +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
1 changed files with 2 additions and 2 deletions
|
@ -22,7 +22,7 @@ public:
|
||||||
{
|
{
|
||||||
JS::GCPtr<Element const> found_element;
|
JS::GCPtr<Element const> found_element;
|
||||||
static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& 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;
|
found_element = &element;
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
{
|
{
|
||||||
JS::GCPtr<Element> found_element;
|
JS::GCPtr<Element> found_element;
|
||||||
static_cast<NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& 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;
|
found_element = &element;
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue