Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Sep 27, 2024
1 parent 2d462ce commit 31e6ce8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions source/lunasvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ bool Node::isElement() const
TextNode Node::toTextNode() const
{
if(m_node && m_node->isTextNode())
return TextNode(static_cast<SVGTextNode*>(m_node));
return static_cast<SVGTextNode*>(m_node);
return TextNode();
}

Element Node::toElement() const
{
if(m_node && m_node->isElement())
return Element(static_cast<SVGElement*>(m_node));
return static_cast<SVGElement*>(m_node);
return Element();
}

Expand Down Expand Up @@ -405,7 +405,7 @@ NodeList Element::children() const
return NodeList();
NodeList children;
for(const auto& child : element()->children())
children.push_back(Node(child.get()));
children.push_back(child.get());
return children;
}

Expand Down
4 changes: 1 addition & 3 deletions source/svgparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,7 @@ bool StyleSheet::parseRule(std::string_view& input, Rule& rule)
rule.declarations.clear();
if(!parseSelectors(input, rule.selectors))
return false;
if(!parseDeclarations(input, rule.declarations))
return false;
return true;
return parseDeclarations(input, rule.declarations);
}

bool StyleSheet::parseSelectors(std::string_view& input, SelectorList& selectors)
Expand Down
2 changes: 1 addition & 1 deletion source/svgtextelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void SVGTextFragmentsBuilder::handleText(const SVGTextNode* node)
auto currentCharacter = plutovg_text_iterator_next(&it);
if(currentCharacter == '\t' || currentCharacter == '\n' || currentCharacter == '\r')
currentCharacter = ' ';
if(element->white_space() == WhiteSpace::Default && currentCharacter == ' ' && lastCharacter == ' ')
if(currentCharacter == ' ' && lastCharacter == ' ' && element->white_space() == WhiteSpace::Default)
continue;
m_text.push_back(currentCharacter);
lastCharacter = currentCharacter;
Expand Down

0 comments on commit 31e6ce8

Please sign in to comment.