summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2023-04-19 10:49:15 +0200
committerPaul Wicking <paul.wicking@qt.io>2023-04-21 20:57:59 +0200
commit3697632ee6b3e48edfcd6d73da072e58069759a7 (patch)
treebc9fc529bf05ebd119442facc22e365b34b293cb
parent625289dcc8926f532b9032109574904cf6a2c18b (diff)
downloadqttools-3697632ee6b3e48edfcd6d73da072e58069759a7.tar.gz
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 <luca.disera@qt.io>
-rw-r--r--src/qdoc/qdoc/docparser.cpp35
1 files changed, 18 insertions, 17 deletions
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()