summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qlistview_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-07-23 22:25:26 +0300
committerMarc Mutz <marc.mutz@kdab.com>2016-11-30 07:24:52 +0000
commit0cdae477e32a312a02eb6be4d82ed1731f617170 (patch)
tree59c7d1d0b32d029f468dae1adc33d342bec6d1a7 /src/widgets/itemviews/qlistview_p.h
parent2fd3d8ea9e3e1829653942431070a83569bab6eb (diff)
QListViewItem: add constexpr
This class is just a record with a bit of functionality on it. To prevent pessimizing it compared to a C struct with the same contents, mark all operations constexpr and remove the point- less copy ctor (the generated one is just fine). Converge on passing QRect, QSize, QPoint by value. Was mixed cref and value passing before. Saves ~1KiB each in text and data size on an UBSan build, somewhat less, of course, on a normal one. Change-Id: Ibae16792d822ff183a0c542380501978f2108d93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/itemviews/qlistview_p.h')
-rw-r--r--src/widgets/itemviews/qlistview_p.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index 07cbd4036c..47effcdfd9 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -69,28 +69,28 @@ class QListViewItem
friend class QListModeViewBase;
friend class QIconModeViewBase;
public:
- inline QListViewItem()
+ Q_DECL_CONSTEXPR QListViewItem()
: x(-1), y(-1), w(0), h(0), indexHint(-1), visited(0xffff) {}
- inline QListViewItem(QRect r, int i)
+ Q_DECL_CONSTEXPR QListViewItem(QRect r, int i)
: x(r.x()), y(r.y()), w(qMin(r.width(), SHRT_MAX)), h(qMin(r.height(), SHRT_MAX)),
indexHint(i), visited(0xffff) {}
- inline bool operator==(const QListViewItem &other) const {
+ Q_DECL_CONSTEXPR bool operator==(const QListViewItem &other) const {
return (x == other.x && y == other.y && w == other.w && h == other.h &&
indexHint == other.indexHint); }
- inline bool operator!=(const QListViewItem &other) const
+ Q_DECL_CONSTEXPR bool operator!=(const QListViewItem &other) const
{ return !(*this == other); }
- inline bool isValid() const
+ Q_DECL_CONSTEXPR bool isValid() const
{ return rect().isValid() && (indexHint > -1); }
- inline void invalidate()
+ Q_DECL_RELAXED_CONSTEXPR void invalidate()
{ x = -1; y = -1; w = 0; h = 0; }
- inline void resize(const QSize &size)
+ Q_DECL_RELAXED_CONSTEXPR void resize(QSize size)
{ w = qMin(size.width(), SHRT_MAX); h = qMin(size.height(), SHRT_MAX); }
- inline void move(const QPoint &position)
+ Q_DECL_RELAXED_CONSTEXPR void move(QPoint position)
{ x = position.x(); y = position.y(); }
- inline int width() const { return w; }
- inline int height() const { return h; }
+ Q_DECL_CONSTEXPR int width() const { return w; }
+ Q_DECL_CONSTEXPR int height() const { return h; }
private:
- inline QRect rect() const
+ Q_DECL_CONSTEXPR QRect rect() const
{ return QRect(x, y, w, h); }
int x, y;
short w, h;