QMetaObject: port QArgumentType to QByteArrayView
Now that argumentTypesFromString() actually doesn't normalize types anymore, all type names are substrings of the signature, and so QByteArrayView suffices (was: QByteArray) to hold the result. QArgumentType in only used transitively, during QMetaObject member function or QObject::connect() calls, so the source string will also never go out of scope before the QArgumentType object that references it. As a drive-by, make the QArgumentType ctor explicit and port from QVLA::op+=() to emplace_back(). No discernable impact on tst_bench_qobject's connect_disconnect. Task-number: QTBUG-135572 Change-Id: If6544917b9df8191a256dc2a67e31c6b7e5a38cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
afdf37ad8f
commit
6c18b438a3
@ -832,8 +832,7 @@ static void argumentTypesFromString(const char *str, const char *end,
|
||||
--level;
|
||||
++str;
|
||||
}
|
||||
QByteArray argType(begin, str - begin);
|
||||
types += QArgumentType(std::move(argType));
|
||||
types.emplace_back(QByteArrayView{begin, str - begin});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ public:
|
||||
QArgumentType(QMetaType metaType)
|
||||
: _metaType(metaType)
|
||||
{}
|
||||
QArgumentType(const QByteArray &name)
|
||||
: _metaType(QMetaType{qMetaTypeTypeInternal(qToByteArrayViewIgnoringNull(name))}), _name(name)
|
||||
explicit QArgumentType(QByteArrayView name)
|
||||
: _metaType(QMetaType{qMetaTypeTypeInternal(name)}), _name(name)
|
||||
{}
|
||||
QMetaType metaType() const noexcept
|
||||
{ return _metaType; }
|
||||
@ -69,7 +69,7 @@ private:
|
||||
Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QArgumentType)
|
||||
|
||||
QMetaType _metaType;
|
||||
QByteArray _name;
|
||||
QByteArrayView _name;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QArgumentType, Q_RELOCATABLE_TYPE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user