From 0bed456f47d9c13d0158ee336d4a13bcf3a3bda3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 2 May 2020 23:03:39 +0200 Subject: [PATCH] QStandardItemModel: port a local QSet to QDuplicateTracker Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: I59242287debfd1e41c663aa2b88d0d3ea44f43fb Reviewed-by: Lars Knoll --- src/gui/itemmodels/qstandarditemmodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index bc76d0ea60..9bb9d57c4e 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -48,7 +48,7 @@ #include #include #include - +#include #include #include #include @@ -3114,12 +3114,11 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const //remove duplicates childrens { - QSet seen; + QDuplicateTracker seen; while (!stack.isEmpty()) { QStandardItem *itm = stack.pop(); - if (seen.contains(itm)) + if (seen.hasSeen(itm)) continue; - seen.insert(itm); const QVector &childList = itm->d_func()->children; for (int i = 0; i < childList.count(); ++i) {