summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-10 15:42:09 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-10 17:56:24 +0200
commit6eef6e961bada90cdbfd5ef8539eecadf493d7d3 (patch)
treea72e69ff693429263cf8ea2c607d5e2724315cea
parentab02e8629d6272b00fbff24b38ee007358f184a1 (diff)
downloadqtlocation-6eef6e961bada90cdbfd5ef8539eecadf493d7d3.tar.gz
QDeclarativeSearchResultModel: modify a map's value in-place instead of overwriting
More efficient, because the copy taken from the element in the container must needs detach on the remove call. Calling remove on the element in the container, OTOH, requires no detach (unless the page is otherwise shared, of course). The old code wouldn't detach the whole map when the int was out of range, but that's not the normal case. Change-Id: I2febd591ff78cea86949aa068938a3be4ca115f0 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index 4cfd26dd..c620b9f7 100644
--- a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -973,16 +973,15 @@ QList<QPlaceSearchResult> QDeclarativeSearchResultModel::resultsFromPages() cons
void QDeclarativeSearchResultModel::removePageRow(int row)
{
- QMapIterator<int, QList<QPlaceSearchResult>> i(m_pages);
+ QMutableMapIterator<int, QList<QPlaceSearchResult>> i(m_pages);
int scanned = 0;
while (i.hasNext()) {
i.next();
- QList<QPlaceSearchResult> page = i.value();
+ QList<QPlaceSearchResult> &page = i.value();
scanned += page.size();
if (row >= scanned)
continue;
page.removeAt(row - scanned + page.size());
- m_pages.insert(i.key(), page);
return;
}
}