Port qMetaTypeTypeInternal() from const char* to QByteArrayView
The only caller of the function, QArgumentType, passes QByteArray::constData() to it, and the function then goes around and performs a strlen() in order to feed it into qMetaTypeTypeInternal(). Pass the name as a QByteArrayView, to save the strlen() over a string we already knew the length of. No measurable performance impact. Task-number: QTBUG-135572 Change-Id: Ifccea7644ce86308df5fb7063c0269a579785504 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit cac63042b1303511ef41642b3290e6d54d1a76b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c4b7c7b097
commit
95fd5fc0d2
@ -36,7 +36,7 @@ using namespace QtMocConstants;
|
||||
Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(MetaObjectFlags)
|
||||
|
||||
Q_CORE_EXPORT int qMetaTypeTypeInternal(const char *);
|
||||
Q_CORE_EXPORT int qMetaTypeTypeInternal(QByteArrayView name);
|
||||
|
||||
class QArgumentType
|
||||
{
|
||||
@ -46,7 +46,7 @@ public:
|
||||
: _metaType(metaType)
|
||||
{}
|
||||
QArgumentType(const QByteArray &name)
|
||||
: _metaType(QMetaType(qMetaTypeTypeInternal(name.constData()))), _name(name)
|
||||
: _metaType(QMetaType{qMetaTypeTypeInternal(qToByteArrayViewIgnoringNull(name))}), _name(name)
|
||||
{}
|
||||
QMetaType metaType() const noexcept
|
||||
{ return _metaType; }
|
||||
|
@ -2897,9 +2897,9 @@ static inline int qMetaTypeTypeImpl(const char *typeName, int length)
|
||||
doesn't attempt to normalize the type name (i.e., the lookup will fail
|
||||
for type names in non-normalized form).
|
||||
*/
|
||||
Q_CORE_EXPORT int qMetaTypeTypeInternal(const char *typeName)
|
||||
Q_CORE_EXPORT int qMetaTypeTypeInternal(QByteArrayView name)
|
||||
{
|
||||
return qMetaTypeTypeImpl<DontNormalizeType>(typeName, int(qstrlen(typeName)));
|
||||
return qMetaTypeTypeImpl<DontNormalizeType>(name.data(), name.size());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user