From 6eef6e961bada90cdbfd5ef8539eecadf493d7d3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 10 Jul 2019 15:42:09 +0200 Subject: 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 --- src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp | 5 ++--- 1 file 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 QDeclarativeSearchResultModel::resultsFromPages() cons void QDeclarativeSearchResultModel::removePageRow(int row) { - QMapIterator> i(m_pages); + QMutableMapIterator> i(m_pages); int scanned = 0; while (i.hasNext()) { i.next(); - QList page = i.value(); + QList &page = i.value(); scanned += page.size(); if (row >= scanned) continue; page.removeAt(row - scanned + page.size()); - m_pages.insert(i.key(), page); return; } } -- cgit v1.2.3