Skip to content

Commit

Permalink
Avoid double hash map look up in SVGElement::updateRelativeLengthsInf…
Browse files Browse the repository at this point in the history
…ormation()

https://bugs.webkit.org/show_bug.cgi?id=260803

Reviewed by Ryosuke Niwa.

Avoid double hash map look up in SVGElement::updateRelativeLengthsInformation()
and do minor code cleanup.

* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::updateRelativeLengthsInformation):

Canonical link: https://commits.webkit.org/267358@main
  • Loading branch information
cdumez committed Aug 28, 2023
1 parent 7378cf3 commit 29181a1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Source/WebCore/svg/SVGElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,16 +1063,13 @@ void SVGElement::updateRelativeLengthsInformation(bool hasRelativeLengths, SVGEl
if (hasRelativeLengths)
m_elementsWithRelativeLengths.add(element);
else {
bool neverRegistered = !m_elementsWithRelativeLengths.contains(element);
if (neverRegistered)
if (!m_elementsWithRelativeLengths.remove(element))
return;

m_elementsWithRelativeLengths.remove(element);
}

if (is<SVGGraphicsElement>(element)) {
if (RefPtr parent = parentNode(); is<SVGElement>(parent))
downcast<SVGElement>(*parent).updateRelativeLengthsInformation(hasRelativeLengths, *this);
if (RefPtr parent = dynamicDowncast<SVGElement>(parentNode()))
parent->updateRelativeLengthsInformation(hasRelativeLengths, *this);
}
}

Expand Down

0 comments on commit 29181a1

Please sign in to comment.