summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-23 19:54:49 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-12 20:09:36 +0200
commit48b38fb2b042fba5a0e1aed4f6d4fa6f29a51af0 (patch)
tree9d143484ccbdb188fa33a00439c617c14c544009 /src
parent6daea46918d95ed6b66eaea22e1f72658a1f997b (diff)
Simple optimisation for the construction of a QSharedPointer
Let the constructor initialise the "value" member. In the case of create(), which already initialised "value", simply merge the two functions for more readability. Change-Id: I5638b3d42af3d0f5988f815e0f91d591fa1897a8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index db4a0587d2..d22ceb2d69 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -294,7 +294,7 @@ public:
QSharedPointer() : value(0), d(0) { }
~QSharedPointer() { deref(); }
- inline explicit QSharedPointer(T *ptr) // throws
+ inline explicit QSharedPointer(T *ptr) : value(ptr) // noexcept
{ internalConstruct(ptr, &QtSharedPointer::normalDeleter<T>); }
template <typename Deleter>
@@ -380,7 +380,7 @@ public:
static inline QSharedPointer<T> create()
{
QSharedPointer<T> result(Qt::Uninitialized);
- result.internalCreate();
+ result.d = QtSharedPointer::ExternalRefCountWithContiguousData<T>::create(&result.value);
// now initialize the data
new (result.data()) T();
@@ -413,15 +413,9 @@ private:
internalFinishConstruction(ptr);
}
- inline void internalCreate()
- {
- d = QtSharedPointer::ExternalRefCountWithContiguousData<T>::create(&value);
- }
-
inline void internalFinishConstruction(T *ptr)
{
- value = ptr;
- if (ptr) d->setQObjectShared(ptr, true);
+ d->setQObjectShared(ptr, true);
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
if (ptr) internalSafetyCheckAdd(d, ptr);
#endif