From 8bc1049ad70b61209905f38340f327289b5dc083 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 21 May 2023 23:14:38 +0300 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira --- src/tools/moc/generator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 75f1ce00ff..e2a9fd8528 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -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); } }