Skip to content

Commit 5103460

Browse files
committed
Change iterator++ to ++iterator (cppcheck)
As iterators are non-primitive types, it's actually preferrable to use pre-increment rather than post-increment. Additionally, collapsed a while loop to a for loop to match the vast majority of iterator loops in the surrounding code.
1 parent a1bb00e commit 5103460

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

mythtv/libs/libmythbase/mythcommandlineparser.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ QString CommandLineArg::GetLongHelpString(QString keyword) const
200200
bool first = true;
201201

202202
QStringList::const_iterator i1;
203-
i1 = m_keywords.begin();
204-
while (i1 != m_keywords.end())
203+
for (i1 = m_keywords.begin(); i1 != m_keywords.end(); ++i1)
205204
{
206205
if (*i1 != keyword)
207206
{
@@ -213,7 +212,6 @@ QString CommandLineArg::GetLongHelpString(QString keyword) const
213212
else
214213
msg << " " << *i1 << endl;
215214
}
216-
i1++;
217215
}
218216

219217
msg << "Type: " << QVariant::typeToName(m_type) << endl;
@@ -766,7 +764,7 @@ void CommandLineArg::PrintVerbose(void) const
766764
tmpmap = m_stored.toMap();
767765
first = true;
768766

769-
for (it = tmpmap.begin(); it != tmpmap.end(); it++)
767+
for (it = tmpmap.begin(); it != tmpmap.end(); ++it)
770768
{
771769
if (first)
772770
first = false;
@@ -1283,7 +1281,7 @@ bool MythCommandLineParser::ReconcileLinks(void)
12831281
{
12841282
if ((*i2)->m_type != QVariant::Invalid)
12851283
{
1286-
i2++;
1284+
++i2;
12871285
continue; // already handled
12881286
}
12891287

@@ -1301,7 +1299,7 @@ bool MythCommandLineParser::ReconcileLinks(void)
13011299
.toLocal8Bit().constData()
13021300
<< endl;
13031301
(*i1)->SetBlocks(m_namedArgs[(*i2)->m_name]);
1304-
i2++;
1302+
++i2;
13051303
}
13061304
}
13071305

0 commit comments

Comments
 (0)