tracepointgen: fix inefficient loops, add a const

Take the loop variable by cref.
Make one loop variable const that was ok to be taken by value.

Coverity-Id: 404395
Coverity-Id: 404396
Coverity-Id: 404397
Coverity-Id: 404398
Coverity-Id: 404399
Pick-to: 6.5
Change-Id: Ib90a8f12b98c892314f10a9a3cb2f3c5c19a5d78
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
This commit is contained in:
Marc Mutz 2023-03-10 18:38:14 +01:00
parent 6fd163f627
commit 3e1108aa7f

View File

@ -131,7 +131,7 @@ static QString preprocessMetadata(const QString &in)
int Parser::lineNumber(qsizetype offset) const
{
DEBUGPRINTF(printf("tracepointgen: lineNumber: offset %u, line count: %u\n", offset , m_offsets.size()));
for (auto line : m_offsets) {
for (const auto line : m_offsets) {
DEBUGPRINTF(printf("tracepointgen: lineNumber: %d %d %d\n", line.begin, line.end, line.line));
if (offset >= line.begin && offset <= line.end)
return line.line;
@ -585,16 +585,16 @@ void Parser::write(QIODevice &input) const
QTextStream out(&input);
if (m_prefixes.size() > 0) {
out << QStringLiteral("{\n");
for (auto prefix : m_prefixes)
for (const auto &prefix : m_prefixes)
out << prefix << "\n";
out << QStringLiteral("}\n");
}
for (auto m : m_metadata)
for (const auto &m : m_metadata)
out << m << "\n";
for (auto func : m_functions) {
for (const auto &func : m_functions) {
out << func.className << "_" << func.functionName << "_entry(" << func.functionParameters << ")\n";
out << func.className << "_" << func.functionName << "_exit()\n";
}
for (auto point : m_points)
for (const auto &point : m_points)
out << point.name << "(" << point.parameters << ")\n";
}