From 3fc09372fbb25a525e58960aca22138dae368f1e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2017 19:58:04 +0100 Subject: [PATCH] QScriptItem: reduce boilerplate code The class does not need to be exported, as it is all-inline, and non-polymorphic. The class also does not need a default ctor, except that QVector requires it, so make the default ctor private and grant QVector friendship. Add constexpr and noexcept. Mark as primitive instead of movable. Change-Id: Ia5d11de8eb993cb080002804e11176dc5226a04c Reviewed-by: Thiago Macieira --- src/gui/text/qtextengine_p.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index f49e2638f5..89f1328241 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -323,13 +323,9 @@ public: QFontEngine *fontEngine; }; -struct Q_AUTOTEST_EXPORT QScriptItem +struct QScriptItem { - inline QScriptItem() - : position(0), - num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), - glyph_data_offset(0) {} - inline QScriptItem(int p, const QScriptAnalysis &a) + Q_DECL_CONSTEXPR QScriptItem(int p, QScriptAnalysis a) Q_DECL_NOTHROW : position(p), analysis(a), num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), glyph_data_offset(0) {} @@ -342,11 +338,12 @@ struct Q_AUTOTEST_EXPORT QScriptItem QFixed leading; QFixed width; int glyph_data_offset; - QFixed height() const { return ascent + descent; } + Q_DECL_CONSTEXPR QFixed height() const Q_DECL_NOTHROW { return ascent + descent; } +private: + friend class QVector; + QScriptItem() {}; // for QVector, don't use }; - - -Q_DECLARE_TYPEINFO(QScriptItem, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QScriptItem, Q_PRIMITIVE_TYPE); typedef QVector QScriptItemArray;