diff options
author | Paul Wicking <paul.wicking@qt.io> | 2019-12-09 18:42:56 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2019-12-10 20:00:26 +0100 |
commit | 77f9699a7c336e67a2ae6d37b75411528954c705 (patch) | |
tree | d55d3781088208df4b850f7528a46dd243db884d /src/qdoc/cppcodeparser.cpp | |
parent | 88b135fb74689484dfa60ee0efd378d85a9f0a75 (diff) | |
download | qttools-77f9699a7c336e67a2ae6d37b75411528954c705.tar.gz |
QDoc: Clean up loops with iterators
- Use ranged-based fors where applicable.
- Use auto keyword for iterators.
- Move a few variable declarations to where they're to be used.
- Update docs where applicable.
Fixes: QTBUG-80536
Change-Id: I859440b96428dec4ef108b01d391479d3f8dbd83
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index b05e2ab3c..84e383fc2 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -712,15 +712,10 @@ void CppCodeParser::processMetaCommands(const Doc &doc, Node *node) { QStringList metaCommandsUsed = doc.metaCommandsUsed().values(); metaCommandsUsed.sort(); // TODO: why are these sorted? mws 24/12/2018 - QStringList::ConstIterator cmd = metaCommandsUsed.constBegin(); - while (cmd != metaCommandsUsed.constEnd()) { - ArgList args = doc.metaCommandArgs(*cmd); - ArgList::ConstIterator arg = args.constBegin(); - while (arg != args.constEnd()) { - processMetaCommand(doc, *cmd, *arg, node); - ++arg; - } - ++cmd; + for (const auto &command : metaCommandsUsed) { + const ArgList args = doc.metaCommandArgs(command); + for (const auto &arg : args) + processMetaCommand(doc, command, arg, node); } } @@ -986,18 +981,17 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL } } else if (args.size() > 1) { QVector<SharedCommentNode *> sharedCommentNodes; - ArgList::ConstIterator arg = args.constBegin(); - while (arg != args.constEnd()) { + for (const auto &arg : qAsConst(args)) { node = nullptr; if (topic == COMMAND_FN) { if (showInternal() || !doc.isInternal()) - node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg->first); + node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg.first); } else if (topic == COMMAND_MACRO) { - node = parseMacroArg(doc.location(), arg->first); + node = parseMacroArg(doc.location(), arg.first); } else if (isQMLMethodTopic(topic) || isJSMethodTopic(topic)) { - node = parseOtherFuncArg(topic, doc.location(), arg->first); + node = parseOtherFuncArg(topic, doc.location(), arg.first); } else { - node = processTopicCommand(doc, topic, *arg); + node = processTopicCommand(doc, topic, arg); } if (node != nullptr) { bool found = false; @@ -1015,7 +1009,6 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL docs.append(doc); } } - ++arg; } } } @@ -1023,15 +1016,14 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) { - NodeList::Iterator n = nodes.begin(); QList<Doc>::Iterator d = docs.begin(); - while (n != nodes.end()) { - if (*n != nullptr) { - processMetaCommands(*d, *n); - (*n)->setDoc(*d); - checkModuleInclusion(*n); - if ((*n)->isAggregate()) { - Aggregate *aggregate = static_cast<Aggregate *>(*n); + for (const auto &node : nodes) { + if (node != nullptr) { + processMetaCommands(*d, node); + node->setDoc(*d); + checkModuleInclusion(node); + if (node->isAggregate()) { + Aggregate *aggregate = static_cast<Aggregate *>(node); if (aggregate->includeFiles().isEmpty()) { Aggregate *parent = aggregate; while (parent->physicalModuleName().isEmpty() && (parent->parent() != nullptr)) @@ -1044,7 +1036,6 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) } } ++d; - ++n; } } |