diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-15 13:48:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-15 16:16:56 +0200 |
commit | d9c64ee876caf2208f90835004f915ca27aed666 (patch) | |
tree | affbf41a8e4923f746a5683f79715a0b90b15105 | |
parent | 8deced39a87125603e082b2481448557b7f4f92b (diff) | |
download | serenity-d9c64ee876caf2208f90835004f915ca27aed666.zip |
LibWeb: Hoist case sensitivity check out of loop in Element::has_class()
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 874494cc6d..e5963cb29b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -251,11 +251,15 @@ Vector<String> Element::get_attribute_names() const bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const { - return any_of(m_classes, [&](auto& it) { - return case_sensitivity == CaseSensitivity::CaseSensitive - ? it == class_name - : it.equals_ignoring_case(class_name); - }); + if (case_sensitivity == CaseSensitivity::CaseSensitive) { + return any_of(m_classes, [&](auto& it) { + return it == class_name; + }); + } else { + return any_of(m_classes, [&](auto& it) { + return it.equals_ignoring_case(class_name); + }); + } } RefPtr<Layout::Node> Element::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) |