From 562c01d04e6b779c754cc9e7164d48e91b92a0d1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Jul 2015 01:28:47 +0200 Subject: [PATCH] QItemSelectionRange: use ctor-init-list Avoids default-constructing two QPersistentModelIndex instances just to copy-assign to them. Change-Id: I0f3e04e3d202f58905f74df44d37dba27911a927 Reviewed-by: Friedemann Kleint --- src/corelib/itemmodels/qitemselectionmodel.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index e548a49b3d..4013beb539 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -48,12 +48,11 @@ class Q_CORE_EXPORT QItemSelectionRange { public: - inline QItemSelectionRange() {} + inline QItemSelectionRange() : tl(), br() {} inline QItemSelectionRange(const QItemSelectionRange &other) : tl(other.tl), br(other.br) {} - inline QItemSelectionRange(const QModelIndex &topLeft, const QModelIndex &bottomRight); - explicit inline QItemSelectionRange(const QModelIndex &index) - { tl = index; br = tl; } + QItemSelectionRange(const QModelIndex &topL, const QModelIndex &bottomR) : tl(topL), br(bottomR) {} + explicit QItemSelectionRange(const QModelIndex &index) : tl(index), br(tl) {} void swap(QItemSelectionRange &other) Q_DECL_NOTHROW { @@ -139,10 +138,6 @@ private: }; Q_DECLARE_TYPEINFO(QItemSelectionRange, Q_MOVABLE_TYPE); -inline QItemSelectionRange::QItemSelectionRange(const QModelIndex &atopLeft, - const QModelIndex &abottomRight) -{ tl = atopLeft; br = abottomRight; } - class QItemSelection; class QItemSelectionModelPrivate;