summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-01-03 11:24:07 -0200
committerThiago Macieira <thiago.macieira@intel.com>2016-01-12 19:25:29 +0000
commit9f09fed72f87c9379fcbfd51cd6463b5c470814f (patch)
tree76f47269b9e88ff058e90738ecd7d2c038315ebf
parent5e1a5a78d912896b7e03ac01f336ed1b109a2b22 (diff)
QVariant: use v_construct instead of duplicating logic
v_construct does what we want, so use it. This is required for the next commit, which solves a GCC 6 warning issue. Change-Id: Ibc83b9f7e3bc4962ae35ffff1425ed5f035f631a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
-rw-r--r--src/corelib/kernel/qvariant_p.h35
1 files changed, 4 insertions, 31 deletions
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 4a090b5f12..4a7df1ad8d 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -116,13 +117,13 @@ inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
if (!QVariantIntegrator<T>::CanUseInternalSpace) {
x->data.shared = copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T *>(copy))
: new QVariantPrivateSharedEx<T>;
- x->is_shared = true;
} else {
if (copy)
new (&x->data.ptr) T(*static_cast<const T *>(copy));
else
new (&x->data.ptr) T();
}
+ x->is_shared = !QVariantIntegrator<T>::CanUseInternalSpace;
}
template <class T>
@@ -130,10 +131,10 @@ inline void v_construct(QVariant::Private *x, const T &t)
{
if (!QVariantIntegrator<T>::CanUseInternalSpace) {
x->data.shared = new QVariantPrivateSharedEx<T>(t);
- x->is_shared = true;
} else {
new (&x->data.ptr) T(t);
}
+ x->is_shared = !QVariantIntegrator<T>::CanUseInternalSpace;
}
// deletes the internal structures
@@ -327,39 +328,11 @@ protected:
template<class Filter>
class QVariantConstructor
{
- template<typename T, bool CanUseInternalSpace = QVariantIntegrator<T>::CanUseInternalSpace>
- struct CallConstructor {};
-
- template<typename T>
- struct CallConstructor<T, /* CanUseInternalSpace = */ true>
- {
- CallConstructor(const QVariantConstructor &tc)
- {
- if (tc.m_copy)
- new (&tc.m_x->data.ptr) T(*static_cast<const T*>(tc.m_copy));
- else
- new (&tc.m_x->data.ptr) T();
- tc.m_x->is_shared = false;
- }
- };
-
- template<typename T>
- struct CallConstructor<T, /* CanUseInternalSpace = */ false>
- {
- CallConstructor(const QVariantConstructor &tc)
- {
- Q_STATIC_ASSERT(QTypeInfo<T>::isComplex || sizeof(T) > sizeof(QVariant::Private::Data));
- tc.m_x->data.shared = tc.m_copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T*>(tc.m_copy))
- : new QVariantPrivateSharedEx<T>;
- tc.m_x->is_shared = true;
- }
- };
-
template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted>
struct FilteredConstructor {
FilteredConstructor(const QVariantConstructor &tc)
{
- CallConstructor<T> tmp(tc);
+ v_construct<T>(tc.m_x, tc.m_copy);
tc.m_x->is_null = !tc.m_copy;
}
};