From 625289dcc8926f532b9032109574904cf6a2c18b Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 19 Apr 2023 10:47:23 +0200 Subject: QDoc: Flatten DocParser::enterPara() 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: I611a69bfd8850ff59e726b10d22801a3fac0527f Reviewed-by: Luca Di Sera --- src/qdoc/qdoc/docparser.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qdoc/qdoc/docparser.cpp b/src/qdoc/qdoc/docparser.cpp index 6702d8ed2..9c6492973 100644 --- a/src/qdoc/qdoc/docparser.cpp +++ b/src/qdoc/qdoc/docparser.cpp @@ -1760,26 +1760,26 @@ void DocParser::appendToCode(const QString &markedCode, Atom::AtomType defaultTy void DocParser::enterPara(Atom::AtomType leftType, Atom::AtomType rightType, const QString &string) { - if (m_paragraphState == OutsideParagraph) { + if (m_paragraphState != OutsideParagraph) + return; - if ((m_private->m_text.lastAtom()->type() != Atom::ListItemLeft) - && (m_private->m_text.lastAtom()->type() != Atom::DivLeft) - && (m_private->m_text.lastAtom()->type() != Atom::DetailsLeft)) { - leaveValueList(); - } + if ((m_private->m_text.lastAtom()->type() != Atom::ListItemLeft) + && (m_private->m_text.lastAtom()->type() != Atom::DivLeft) + && (m_private->m_text.lastAtom()->type() != Atom::DetailsLeft)) { + leaveValueList(); + } - append(leftType, string); - m_indexStartedParagraph = false; - m_pendingParagraphLeftType = leftType; - m_pendingParagraphRightType = rightType; - m_pendingParagraphString = string; - if (leftType == Atom::SectionHeadingLeft) { - m_paragraphState = InSingleLineParagraph; - } else { - m_paragraphState = InMultiLineParagraph; - } - skipSpacesOrOneEndl(); + append(leftType, string); + m_indexStartedParagraph = false; + m_pendingParagraphLeftType = leftType; + m_pendingParagraphRightType = rightType; + m_pendingParagraphString = string; + if (leftType == Atom::SectionHeadingLeft) { + m_paragraphState = InSingleLineParagraph; + } else { + m_paragraphState = InMultiLineParagraph; } + skipSpacesOrOneEndl(); } void DocParser::leavePara() -- cgit v1.2.1