From f92fdd190d056fe929f723e3f2ce9e0c0b141cec Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 22 Apr 2012 22:04:46 +0200 Subject: Implement the move constructor for containers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes all the containers that uses QtPrivate::RefCount (QMap already had one), and QVariant In Qt 4.8, it was pointless to have the move constructor because we did not have quick way to re-initialize a null container. (shared_null still needed to be refcounted) But now that we have RefCount, and that the shared_null do not have reference count, we can implement a fast move constructor that do not generate code to increment the reference count. Change-Id: I2bc3c6ae96983f08aa7b1c7cb98d44a89255160b Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qlist.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools/qlist.h') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 0d5b109f2f..ad94781b6f 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -115,7 +115,8 @@ public: ~QList(); QList &operator=(const QList &l); #ifdef Q_COMPILER_RVALUE_REFS - inline QList &operator=(QList &&other) + inline QList(QList &&other) : d(other.d) { other.d = const_cast(&QListData::shared_null); } + inline QList &operator=(QList &&other) { qSwap(d, other.d); return *this; } #endif inline void swap(QList &other) { qSwap(d, other.d); } -- cgit v1.2.3