Moc: simplify code

The concatenated byte array is already the "size" we want.

Drive-by change: use QByteArray::sliced()

Change-Id: Id0afb45ae1daf08bd125230eef0734770c645e1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-05-21 23:14:38 +03:00
parent 475d5266e4
commit 8bc1049ad7

View File

@ -174,14 +174,14 @@ bool Generator::registerableMetaType(const QByteArray &propertyType)
#undef STREAM_1ARG_TEMPLATE
;
for (const QByteArray &oneArgTemplateType : oneArgTemplates) {
QByteArray ba = oneArgTemplateType + "<";
const QByteArray ba = oneArgTemplateType + "<";
if (propertyType.startsWith(ba) && propertyType.endsWith(">")) {
const qsizetype argumentSize = propertyType.size() - oneArgTemplateType.size() - 1
const qsizetype argumentSize = propertyType.size() - ba.size()
// The closing '>'
- 1
// templates inside templates have an extra whitespace char to strip.
- (propertyType.at(propertyType.size() - 2) == ' ' ? 1 : 0 );
const QByteArray templateArg = propertyType.mid(oneArgTemplateType.size() + 1, argumentSize);
const QByteArray templateArg = propertyType.sliced(ba.size(), argumentSize);
return isBuiltinType(templateArg) || registerableMetaType(templateArg);
}
}