aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope_p.h
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-11-22 15:38:44 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2021-11-24 09:27:58 +0100
commit57293e3f90099b9430858280abc8a876cd23ec05 (patch)
treeb86c6f75ebe7712c4d8366236d87f3be06cb7f83 /src/qmlcompiler/qqmljsscope_p.h
parent474afd679213c9c5697166904e1e995c3617f614 (diff)
Further improve QQmlJSMetaPropertyBindings (2/N). Take 3
Make QQmlJSScope insert property bindings in the correct order. We can do this by using some hackery: - insert the element first through the QMultiMap interface - query the non-const equal range and rotate first element to the end The rotate is a bit slow, however, so let's do move left + copy-assign Change-Id: I8f422c8a9105211fb016047c70b51b851c9873d8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsscope_p.h')
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h
index 2bb23ebf63..f3f3e1010e 100644
--- a/src/qmlcompiler/qqmljsscope_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -242,6 +242,12 @@ public:
void addOwnPropertyBinding(const QQmlJSMetaPropertyBinding &binding)
{
m_propertyBindings.insert(binding.propertyName(), binding);
+
+ // NB: insert() prepends \a binding to the list of bindings, but we need
+ // append, so rotate
+ using iter = typename QMultiHash<QString, QQmlJSMetaPropertyBinding>::iterator;
+ QPair<iter, iter> r = m_propertyBindings.equal_range(binding.propertyName());
+ std::rotate(r.first, std::next(r.first), r.second);
}
QMultiHash<QString, QQmlJSMetaPropertyBinding> ownPropertyBindings() const
{