diff options
author | Paul Wicking <paul.wicking@qt.io> | 2023-04-14 11:06:40 +0200 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2023-04-28 11:03:53 +0200 |
commit | acae7fc8f30a4a1eabe6a8439e6f8143b4458847 (patch) | |
tree | 2f6bc3ed29a91f1dd7d0de13cebf77d1eaacdecf | |
parent | 3d814edf5710367bd1e281521a1a1d232d83eef1 (diff) | |
download | qttools-acae7fc8f30a4a1eabe6a8439e6f8143b4458847.tar.gz |
QDoc: Refactor DocParser::insertTarget
A recent refactoring extracted a method from `DocParser::insertTarget`
that allows and early return. This makes the else branch redundant, as
control will always exit the method if the `if` condition is satisfied.
This allows for flattening the method further.
This change thus flattens the method by removing the else statement and
flattening the code in that branch. The remaining code features another
if/else check. This change adds a return statement to the if statement,
allowing the removal of the following else statement and the flattening
of that branch, too.
Task-number: QTBUG-113126
Change-Id: If0e7436f8bb98924dd54c9d9f04a8a7a4d7566a9
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/qdoc/docparser.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/qdoc/qdoc/docparser.cpp b/src/qdoc/qdoc/docparser.cpp index ca17fefba..8ec7a49bf 100644 --- a/src/qdoc/qdoc/docparser.cpp +++ b/src/qdoc/qdoc/docparser.cpp @@ -1309,18 +1309,18 @@ static void warnAboutPreexistingTarget(const Location &location, const QString & void DocParser::insertTarget(const QString &target, bool keyword) { - if (m_targetMap.contains(target)) { + if (m_targetMap.contains(target)) return warnAboutPreexistingTarget(location(), target, m_targetMap[target].toString()); + + m_targetMap.insert(target, location()); + m_private->constructExtra(); + + if (keyword) { + append(Atom::Keyword, target); + m_private->extra->m_keywords.append(m_private->m_text.lastAtom()); } else { - m_targetMap.insert(target, location()); - m_private->constructExtra(); - if (keyword) { - append(Atom::Keyword, target); - m_private->extra->m_keywords.append(m_private->m_text.lastAtom()); - } else { - append(Atom::Target, target); - m_private->extra->m_targets.append(m_private->m_text.lastAtom()); - } + append(Atom::Target, target); + m_private->extra->m_targets.append(m_private->m_text.lastAtom()); } } |