summaryrefslogtreecommitdiffstats
path: root/src/tools/qdbuscpp2xml
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2017-01-06 22:02:50 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2017-01-12 17:54:28 +0000
commitdcec1420ea9d7e90bbd7f37be15d8e61eaf35d23 (patch)
tree950020aadfc183963a5668263ef302d8d6b0e6de /src/tools/qdbuscpp2xml
parent8f469e4a19feb77758fb5d3c7120ba93cf32cd7d (diff)
Use QString::asprintf(), QStringBuilder, and the multi-arg overload of QString::arg()
... instead of sequential .arg(const QString &) callings. It saves memory allocations and prevents unexpected results if replacing strings contain place markers. Found with clazy's qstring-arg check. Change-Id: I3912275a6e11c6fb7559ff5623f2e8cde9b7f07a Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/qdbuscpp2xml')
-rw-r--r--src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
index 26e7b086d9..efce778acf 100644
--- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
@@ -103,9 +103,8 @@ static inline QString typeNameToXml(const char *typeName)
static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
- QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n")
- .arg(isSignal ? QLatin1String("signal") : QLatin1String("method"))
- .arg(QLatin1String(mm.name));
+ QString xml = QString::asprintf(" <%s name=\"%s\">\n",
+ isSignal ? "signal" : "method", mm.name.constData());
// check the return type first
int typeId = QMetaType::type(mm.normalizedType.constData());
@@ -156,9 +155,9 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
const char *signature = QDBusMetaType::typeToSignature(types.at(j));
xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n")
- .arg(name)
- .arg(QLatin1String(signature))
- .arg(isOutput ? QLatin1String("out") : QLatin1String("in"));
+ .arg(name,
+ QLatin1String(signature),
+ isOutput ? QLatin1String("out") : QLatin1String("in"));
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
@@ -220,9 +219,9 @@ static QString generateInterfaceXml(const ClassDef *mo)
continue;
retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
- .arg(QLatin1String(mp.name))
- .arg(QLatin1String(signature))
- .arg(QLatin1String(accessvalues[access]));
+ .arg(QLatin1String(mp.name),
+ QLatin1String(signature),
+ QLatin1String(accessvalues[access]));
if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")