From acae7fc8f30a4a1eabe6a8439e6f8143b4458847 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 14 Apr 2023 11:06:40 +0200 Subject: QDoc: Refactor DocParser::insertTarget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ƶ --- src/qdoc/qdoc/docparser.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') 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()); } } -- cgit v1.2.1