summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorAnton Kudryavtsev <antkudr@mail.ru>2017-03-19 14:19:22 +0300
committerAnton Kudryavtsev <antkudr@mail.ru>2017-03-28 11:15:33 +0000
commitbae0c4c11a6dda52e5d1e9d6d7d0de3ebd47642b (patch)
tree4cf8fb5706002c5569d15546184ff8f5a236c8c7 /src/widgets
parent81b5aa792f84747962cb05e0cf11708e4466bf30 (diff)
Avoid expensive QHash::values() calls
qcocoawindow.mm: we can replace QHash::values() with std::vector since CoW is needless here and std::vector is more cache-friendly. Also replace foreach with range-based for. qitemeditorfactory.cpp: QHash::values() is used as auxiliary container to create QSet. Replace it with std::vector since CoW is needless here and apply sort-unique idiom to remove duplicates. Also avoid needless allocations. Change-Id: If34c7016977ceb7fab68e9298bf2e1944af79139 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index c044d37575..c535cf5f9e 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -55,6 +55,7 @@
#include <qapplication.h>
#include <qdebug.h>
+#include <vector>
#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -191,9 +192,11 @@ QByteArray QItemEditorFactory::valuePropertyName(int userType) const
QItemEditorFactory::~QItemEditorFactory()
{
//we make sure we delete all the QItemEditorCreatorBase
- //this has to be done only once, hence the QSet
- QSet<QItemEditorCreatorBase*> set = creatorMap.values().toSet();
- qDeleteAll(set);
+ //this has to be done only once, hence the sort-unique idiom
+ std::vector<QItemEditorCreatorBase*> creators(creatorMap.cbegin(), creatorMap.cend());
+ std::sort(creators.begin(), creators.end());
+ const auto it = std::unique(creators.begin(), creators.end());
+ qDeleteAll(creators.begin(), it);
}
/*!