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 <thiago.macieira@intel.com>
This commit is contained in:
parent
d37e70c4bc
commit
3fc09372fb
@ -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>;
|
||||
QScriptItem() {}; // for QVector, don't use
|
||||
};
|
||||
|
||||
|
||||
Q_DECLARE_TYPEINFO(QScriptItem, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QScriptItem, Q_PRIMITIVE_TYPE);
|
||||
|
||||
typedef QVector<QScriptItem> QScriptItemArray;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user