diff options
author | Paul Wicking <paul.wicking@qt.io> | 2019-12-06 13:26:52 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2019-12-11 07:52:57 +0100 |
commit | c09c14b1da8cf7ad6f844230ca552719776e981d (patch) | |
tree | 70a4625a9d6c8e52e44c7f4c2cf43e7b9b7422e7 | |
parent | c76e840e47113514fa786093bb9dd4fadf432490 (diff) | |
download | qttools-c09c14b1da8cf7ad6f844230ca552719776e981d.tar.gz |
QDoc: Minor adjustment/cleanup
Pre-increment instead of post-increment for efficiency and readability.
Change-Id: I10b33360dd36cd1d0f4338441c1ad4724551e80e
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/atom.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/config.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/doc.cpp | 84 | ||||
-rw-r--r-- | src/qdoc/editdistance.cpp | 10 | ||||
-rw-r--r-- | src/qdoc/node.cpp | 2 |
7 files changed, 59 insertions, 59 deletions
diff --git a/src/qdoc/atom.cpp b/src/qdoc/atom.cpp index dff90b299..ecbea2013 100644 --- a/src/qdoc/atom.cpp +++ b/src/qdoc/atom.cpp @@ -334,7 +334,7 @@ QString Atom::typeString() const while (atms[i].english != nullptr) { if (atms[i].no != i) Location::internalError(QCoreApplication::translate("QDoc::Atom", "atom %1 missing").arg(i)); - i++; + ++i; } deja = true; } diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 605edeb86..2e96a092d 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -269,7 +269,7 @@ static Node *findNodeForCursor(QDocDatabase *qdb, CXCursor cur) { if (isVariadic && parameters.last().type() != QLatin1String("...")) continue; bool different = false; - for (int i = 0; i < actualArg; i++) { + for (int i = 0; i < actualArg; ++i) { if (args.size() <= i) args.append(fromCXString(clang_getTypeSpelling(clang_getArgType(funcType, i)))); QString t1 = parameters.at(i).type(); @@ -347,7 +347,7 @@ static Node *findFunctionNodeForCursor(QDocDatabase *qdb, CXCursor cur) { if (isVariadic && parameters.last().type() != QLatin1String("...")) continue; bool different = false; - for (int i = 0; i < numArg; i++) { + for (int i = 0; i < numArg; ++i) { if (args.size() <= i) args.append(fromCXString(clang_getTypeSpelling(clang_getArgType(funcType, i)))); QString t1 = parameters.at(i).type(); @@ -884,7 +884,7 @@ void ClangVisitor::readParameterNamesAndAttributes(FunctionNode *fn, CXCursor cu } return CXChildVisit_Continue; }); - i++; + ++i; } return CXChildVisit_Continue; }); @@ -1521,7 +1521,7 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg QString pName = blankSplit.last(); int j = 0; while (j < pName.length() && !pName.at(i).isLetter()) - j++; + ++j; if (j > 0) pName = pName.mid(j); if (!pName.isEmpty() && pName != parameters[i].name()) diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index ed80af464..da641d3ea 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -259,7 +259,7 @@ QMap<QString, QStringList> Config::includeFilesMap_; Config::Config(const QString &programName, const QStringList &args) : prog(programName) { - numInstances++; + ++numInstances; processCommandLineOptions(args); reset(); } @@ -921,7 +921,7 @@ QString Config::copyFile(const Location &location, int Config::numParams(const QString &value) { int max = 0; - for (int i = 0; i != value.length(); i++) { + for (int i = 0; i != value.length(); ++i) { uint c = value[i].unicode(); if (c > 0 && c < 8) max = qMax(max, static_cast<int>(c)); diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index 251f0cef6..06e33d09e 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -161,7 +161,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, synopsis += QLatin1Char('('); if (!func->parameters().isEmpty()) { const Parameters ¶meters = func->parameters(); - for (int i = 0; i < parameters.count(); i++) { + for (int i = 0; i < parameters.count(); ++i) { if (i > 0) synopsis += ", "; QString name = parameters.at(i).name(); @@ -337,7 +337,7 @@ QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary) synopsis += QLatin1Char('('); if (!func->parameters().isEmpty()) { const Parameters ¶meters = func->parameters(); - for (int i = 0; i < parameters.count(); i++) { + for (int i = 0; i < parameters.count(); ++i) { if (i > 0) synopsis += ", "; QString name = parameters.at(i).name(); @@ -607,12 +607,12 @@ QString CppCodeMarker::addMarkUp(const QString &in, case '(': finish = i; readChar(); - parenDepth++; + ++parenDepth; break; case ')': finish = i; readChar(); - parenDepth--; + --parenDepth; break; case ':': finish = i; diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp index 889ecf3c2..a038be439 100644 --- a/src/qdoc/doc.cpp +++ b/src/qdoc/doc.cpp @@ -586,12 +586,12 @@ void DocParser::parse(const QString &source, case '\\': { QString cmdStr; backslashPos = pos; - pos++; + ++pos; while (pos < len) { ch = input_.at(pos); if (ch.isLetterOrNumber()) { cmdStr += ch; - pos++; + ++pos; } else { break; @@ -1452,12 +1452,12 @@ void DocParser::parse(const QString &source, case '{': enterPara(); appendChar('{'); - braceDepth++; - pos++; + ++braceDepth; + ++pos; break; case '}': { - braceDepth--; - pos++; + --braceDepth; + ++pos; auto format = pendingFormats.find(braceDepth); if (format == pendingFormats.end()) { @@ -1642,7 +1642,7 @@ QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet, int i = 0; while (cmds[i].english != nullptr) { commandSet.insert(*cmds[i].alias); - i++; + ++i; } if (aliasMap()->contains(str)) @@ -2179,7 +2179,7 @@ void DocParser::expandMacro(const QString &name, QStringList args; QString rawString; - for (int i = 0; i < numParams; i++) { + for (int i = 0; i < numParams; ++i) { if (numParams == 1 || isLeftBraceAhead()) { args << getArgument(true); } @@ -2221,7 +2221,7 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def, rawString = def; } else { QStringList args; - for (int i = 0; i < numParams; i++) { + for (int i = 0; i < numParams; ++i) { if (numParams == 1 || isLeftBraceAhead()) { args << getArgument(true); } @@ -2302,19 +2302,19 @@ QString DocParser::getBracedArgument(bool verbatim) QString arg; int delimDepth = 0; if (pos < input_.length() && input_[pos] == '{') { - pos++; + ++pos; while (pos < input_.length() && delimDepth >= 0) { switch (input_[pos].unicode()) { case '{': - delimDepth++; + ++delimDepth; arg += QLatin1Char('{'); - pos++; + ++pos; break; case '}': - delimDepth--; + --delimDepth; if (delimDepth >= 0) arg += QLatin1Char('}'); - pos++; + ++pos; break; case '\\': if (verbatim || !expandMacro()) @@ -2325,7 +2325,7 @@ QString DocParser::getBracedArgument(bool verbatim) arg += QChar(' '); else arg += input_[pos]; - pos++; + ++pos; } } if (delimDepth > 0) @@ -2362,17 +2362,17 @@ QString DocParser::getArgument(bool verbatim) case '(': case '[': case '{': - delimDepth++; + ++delimDepth; arg += input_[pos]; - pos++; + ++pos; break; case ')': case ']': case '}': - delimDepth--; + --delimDepth; if (pos == startPos || delimDepth >= 0) { arg += input_[pos]; - pos++; + ++pos; } break; case '\\': @@ -2381,7 +2381,7 @@ QString DocParser::getArgument(bool verbatim) break; default: arg += input_[pos]; - pos++; + ++pos; } } endPos = pos; @@ -2389,7 +2389,7 @@ QString DocParser::getArgument(bool verbatim) (QString(".,:;!?").indexOf(input_[pos - 1]) != -1) && !arg.endsWith("...")) { arg.truncate(arg.length() - 1); - pos--; + --pos; } if (arg.length() > 2 && input_.mid(pos - 2, 2) == "'s") { arg.truncate(arg.length() - 2); @@ -2411,27 +2411,27 @@ QString DocParser::getBracketedArgument() int delimDepth = 0; skipSpacesOrOneEndl(); if (pos < input_.length() && input_[pos] == '[') { - pos++; + ++pos; while (pos < input_.length() && delimDepth >= 0) { switch (input_[pos].unicode()) { case '[': - delimDepth++; + ++delimDepth; arg += QLatin1Char('['); - pos++; + ++pos; break; case ']': - delimDepth--; + --delimDepth; if (delimDepth >= 0) arg += QLatin1Char(']'); - pos++; + ++pos; break; case '\\': arg += input_[pos]; - pos++; + ++pos; break; default: arg += input_[pos]; - pos++; + ++pos; } } if (delimDepth > 0) @@ -2586,7 +2586,7 @@ bool DocParser::isBlankLine() while (i < len && input_[i].isSpace()) { if (input_[i] == '\n') return true; - i++; + ++i; } return false; } @@ -2600,7 +2600,7 @@ bool DocParser::isLeftBraceAhead() // ### bug with '\\' if (input_[i] == '\n') numEndl++; - i++; + ++i; } return numEndl < 2 && i < len && input_[i] == '{'; } @@ -2614,7 +2614,7 @@ bool DocParser::isLeftBracketAhead() // ### bug with '\\' if (input_[i] == '\n') numEndl++; - i++; + ++i; } return numEndl < 2 && i < len && input_[i] == '['; } @@ -2647,14 +2647,14 @@ void DocParser::skipSpacesOrOneEndl() break; } } - pos++; + ++pos; } } void DocParser::skipAllSpaces() { while (pos < len && input_[pos].isSpace()) - pos++; + ++pos; } void DocParser::skipToNextPreprocessorCommand() @@ -2740,7 +2740,7 @@ QString DocParser::untabifyEtc(const QString &str) result.reserve(str.length()); int column = 0; - for (int i = 0; i < str.length(); i++) { + for (int i = 0; i < str.length(); ++i) { const QChar c = str.at(i); if (c == QLatin1Char('\r')) continue; @@ -2757,7 +2757,7 @@ QString DocParser::untabifyEtc(const QString &str) continue; } result += c; - column++; + ++column; } while (result.endsWith("\n\n")) @@ -2773,14 +2773,14 @@ int DocParser::indentLevel(const QString &str) int minIndent = INT_MAX; int column = 0; - for (int i = 0; i < str.length(); i++) { + for (int i = 0; i < str.length(); ++i) { if (str[i] == '\n') { column = 0; } else { if (str[i] != ' ' && column < minIndent) minIndent = column; - column++; + ++column; } } return minIndent; @@ -2794,7 +2794,7 @@ QString DocParser::unindent(int level, const QString &str) QString t; int column = 0; - for (int i = 0; i < str.length(); i++) { + for (int i = 0; i < str.length(); ++i) { if (str[i] == QLatin1Char('\n')) { t += '\n'; column = 0; @@ -2802,7 +2802,7 @@ QString DocParser::unindent(int level, const QString &str) else { if (column >= level) t += str[i]; - column++; + ++column; } } return t; @@ -3182,7 +3182,7 @@ void Doc::initialize(const Config &config) if (cmds[i].no != i) Location::internalError(tr("command %1 missing").arg(i)); - i++; + ++i; } for (const auto ¯oName : config.subVars(CONFIG_MACRO)) { @@ -3273,7 +3273,7 @@ void Doc::trimCStyleComment(Location &location, QString &str) int asterColumn = location.columnNo() + 1; int i; - for (i = 0; i < str.length(); i++) { + for (i = 0; i < str.length(); ++i) { if (m.columnNo() == asterColumn) { if (str[i] != '*') break; @@ -3293,7 +3293,7 @@ void Doc::trimCStyleComment(Location &location, QString &str) if (cleaned.length() == str.length()) str = cleaned; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; ++i) location.advance(str[i]); str = str.mid(3, str.length() - 5); } diff --git a/src/qdoc/editdistance.cpp b/src/qdoc/editdistance.cpp index c8451f3c2..ff4630e15 100644 --- a/src/qdoc/editdistance.cpp +++ b/src/qdoc/editdistance.cpp @@ -44,12 +44,12 @@ int editDistance(const QString &s, const QString &t) int *d = new int[m * n]; int result; - for ( i = 0; i < m; i++ ) + for (i = 0; i < m; ++i) D( i, 0 ) = i; - for ( j = 0; j < n; j++ ) + for (j = 0; j < n; ++j) D( 0, j ) = j; - for ( i = 1; i < m; i++ ) { - for ( j = 1; j < n; j++ ) { + for (i = 1; i < m; ++i) { + for (j = 1; j < n; ++j) { if ( s[i - 1] == t[j - 1] ) { D( i, j ) = D( i - 1, j - 1 ); } else { @@ -83,7 +83,7 @@ QString nearestName(const QString &actual, const QSet<QString> &candidates) numBest = 1; best = candidate; } else if (delta == deltaBest) { - numBest++; + ++numBest; } } } diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 08ec638d7..6cd3c74f7 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -2383,7 +2383,7 @@ void Aggregate::adoptFunction(FunctionNode *fn) auto it = functionMap_.find(fn->name()); if (it == functionMap_.end()) functionMap_.insert(fn->name(), fn); - functionCount_++; + ++functionCount_; } /*! |