From 9888e29c14c94fb7883e4134ae4ed278b54ff3f1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 2 Mar 2022 15:15:39 +0100 Subject: [PATCH] LibWeb: Streamline Node::enclosing_link_element() somewhat No need to verify_cast repeatedly once we've confirmed the type. --- Userland/Libraries/LibWeb/DOM/Node.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 4676ef44b6..1342f002ef 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -81,8 +81,11 @@ Node::~Node() const HTML::HTMLAnchorElement* Node::enclosing_link_element() const { for (auto* node = this; node; node = node->parent()) { - if (is(*node) && verify_cast(*node).has_attribute(HTML::AttributeNames::href)) - return verify_cast(node); + if (!is(*node)) + continue; + auto const& anchor_element = static_cast(*node); + if (anchor_element.has_attribute(HTML::AttributeNames::href)) + return &anchor_element; } return nullptr; }