From 3697632ee6b3e48edfcd6d73da072e58069759a7 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 19 Apr 2023 10:49:15 +0200 Subject: QDoc: Flatten DocParser::leavePara() The entire method sits behind an `if`. Inverse the logic of the conditional and return early. This allows for flattening the whole method. Change-Id: I849f089bf4c84b4715eaeb0d2863f7c6fff24c96 Reviewed-by: Luca Di Sera --- src/qdoc/qdoc/docparser.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/qdoc/qdoc/docparser.cpp b/src/qdoc/qdoc/docparser.cpp index 9c6492973..44b0ee3a7 100644 --- a/src/qdoc/qdoc/docparser.cpp +++ b/src/qdoc/qdoc/docparser.cpp @@ -1784,26 +1784,27 @@ void DocParser::enterPara(Atom::AtomType leftType, Atom::AtomType rightType, con void DocParser::leavePara() { - if (m_paragraphState != OutsideParagraph) { - if (!m_pendingFormats.isEmpty()) { - location().warning(QStringLiteral("Missing '}'")); - m_pendingFormats.clear(); - } + if (m_paragraphState == OutsideParagraph) + return; - if (m_private->m_text.lastAtom()->type() == m_pendingParagraphLeftType) { - m_private->m_text.stripLastAtom(); - } else { - if (m_private->m_text.lastAtom()->type() == Atom::String - && m_private->m_text.lastAtom()->string().endsWith(QLatin1Char(' '))) { - m_private->m_text.lastAtom()->chopString(); - } - append(m_pendingParagraphRightType, m_pendingParagraphString); + if (!m_pendingFormats.isEmpty()) { + location().warning(QStringLiteral("Missing '}'")); + m_pendingFormats.clear(); + } + + if (m_private->m_text.lastAtom()->type() == m_pendingParagraphLeftType) { + m_private->m_text.stripLastAtom(); + } else { + if (m_private->m_text.lastAtom()->type() == Atom::String + && m_private->m_text.lastAtom()->string().endsWith(QLatin1Char(' '))) { + m_private->m_text.lastAtom()->chopString(); } - m_paragraphState = OutsideParagraph; - m_indexStartedParagraph = false; - m_pendingParagraphRightType = Atom::Nop; - m_pendingParagraphString.clear(); + append(m_pendingParagraphRightType, m_pendingParagraphString); } + m_paragraphState = OutsideParagraph; + m_indexStartedParagraph = false; + m_pendingParagraphRightType = Atom::Nop; + m_pendingParagraphString.clear(); } void DocParser::leaveValue() -- cgit v1.2.1