Libs: Use qAsConst with non-const Qt containers in range-loops

Change-Id: I00d9f7c1634bbb62191470d58158e1fd150533c0
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Alessandro Portale
2021-02-16 15:01:44 +01:00
parent 72d91dc94a
commit 97a45f7512
13 changed files with 30 additions and 31 deletions

View File

@@ -164,7 +164,7 @@ bool PortList::hasMore() const { return !d->ranges.isEmpty(); }
bool PortList::contains(Port port) const
{
for (const Internal::Range &r : d->ranges) {
for (const Internal::Range &r : qAsConst(d->ranges)) {
if (port >= r.first && port <= r.second)
return true;
}
@@ -174,7 +174,7 @@ bool PortList::contains(Port port) const
int PortList::count() const
{
int n = 0;
for (const Internal::Range &r : d->ranges)
for (const Internal::Range &r : qAsConst(d->ranges))
n += r.second.number() - r.first.number() + 1;
return n;
}
@@ -194,7 +194,7 @@ Port PortList::getNext()
QString PortList::toString() const
{
QString stringRep;
for (const Internal::Range &range : d->ranges) {
for (const Internal::Range &range : qAsConst(d->ranges)) {
stringRep += QString::number(range.first.number());
if (range.second != range.first)
stringRep += QLatin1Char('-') + QString::number(range.second.number());