QtDBus: use new QLatin1String::arg()
Saves more than 4KiB in text size (~0.7%) on optimized GCC 9.1 Linux AMD64 builds. Change-Id: I5b29eae620370abd91e3a7f98e660c32470aed1c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
9c357d64db
commit
f8f4a75d82
@ -164,7 +164,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
|
||||
"used to read property %s.%s",
|
||||
mp.typeName(), qPrintable(interface), mp.name());
|
||||
lastError = QDBusError(QDBusError::Failed,
|
||||
QString::fromLatin1("Unregistered type %1 cannot be handled")
|
||||
QLatin1String("Unregistered type %1 cannot be handled")
|
||||
.arg(QLatin1String(mp.typeName())));
|
||||
return false;
|
||||
}
|
||||
@ -220,15 +220,15 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
|
||||
}
|
||||
|
||||
// there was an error...
|
||||
QString errmsg = QLatin1String("Unexpected `%1' (%2) when retrieving property `%3.%4' "
|
||||
"(expected type `%5' (%6))");
|
||||
const auto errmsg = QLatin1String("Unexpected `%1' (%2) when retrieving property `%3.%4' "
|
||||
"(expected type `%5' (%6))");
|
||||
lastError = QDBusError(QDBusError::InvalidSignature,
|
||||
errmsg.arg(QString::fromLatin1(foundType),
|
||||
QString::fromLatin1(foundSignature),
|
||||
errmsg.arg(QLatin1String(foundType),
|
||||
QLatin1String(foundSignature),
|
||||
interface,
|
||||
QString::fromUtf8(mp.name()),
|
||||
QString::fromLatin1(mp.typeName()),
|
||||
QString::fromLatin1(expectedSignature)));
|
||||
QLatin1String(mp.name()),
|
||||
QLatin1String(mp.typeName()),
|
||||
QLatin1String(expectedSignature)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -340,8 +340,9 @@ static QByteArray buildMatchRule(const QString &service,
|
||||
const QString &objectPath, const QString &interface,
|
||||
const QString &member, const QDBusConnectionPrivate::ArgMatchRules &argMatch, const QString & /*signature*/)
|
||||
{
|
||||
QString result = QLatin1String("type='signal',");
|
||||
QString keyValue = QLatin1String("%1='%2',");
|
||||
QString result;
|
||||
result += QLatin1String("type='signal',");
|
||||
const auto keyValue = QLatin1String("%1='%2',");
|
||||
|
||||
if (!service.isEmpty())
|
||||
result += keyValue.arg(QLatin1String("sender"), service);
|
||||
@ -354,13 +355,13 @@ static QByteArray buildMatchRule(const QString &service,
|
||||
|
||||
// add the argument string-matching now
|
||||
if (!argMatch.args.isEmpty()) {
|
||||
keyValue = QLatin1String("arg%1='%2',");
|
||||
const QString keyValue = QLatin1String("arg%1='%2',");
|
||||
for (int i = 0; i < argMatch.args.count(); ++i)
|
||||
if (!argMatch.args.at(i).isNull())
|
||||
result += keyValue.arg(i).arg(argMatch.args.at(i));
|
||||
}
|
||||
if (!argMatch.arg0namespace.isEmpty()) {
|
||||
result += QStringLiteral("arg0namespace='%1',").arg(argMatch.arg0namespace);
|
||||
result += QLatin1String("arg0namespace='%1',").arg(argMatch.arg0namespace);
|
||||
}
|
||||
|
||||
result.chop(1); // remove ending comma
|
||||
@ -1369,19 +1370,19 @@ void QDBusConnectionPrivate::sendError(const QDBusMessage &msg, QDBusError::Erro
|
||||
if (msg.interface().isEmpty())
|
||||
interfaceMsg = QLatin1String("any interface");
|
||||
else
|
||||
interfaceMsg = QString::fromLatin1("interface '%1'").arg(msg.interface());
|
||||
interfaceMsg = QLatin1String("interface '%1'").arg(msg.interface());
|
||||
|
||||
send(msg.createErrorReply(code,
|
||||
QString::fromLatin1("No such method '%1' in %2 at object path '%3' "
|
||||
"(signature '%4')")
|
||||
QLatin1String("No such method '%1' in %2 at object path '%3' "
|
||||
"(signature '%4')")
|
||||
.arg(msg.member(), interfaceMsg, msg.path(), msg.signature())));
|
||||
} else if (code == QDBusError::UnknownInterface) {
|
||||
send(msg.createErrorReply(QDBusError::UnknownInterface,
|
||||
QString::fromLatin1("No such interface '%1' at object path '%2'")
|
||||
QLatin1String("No such interface '%1' at object path '%2'")
|
||||
.arg(msg.interface(), msg.path())));
|
||||
} else if (code == QDBusError::UnknownObject) {
|
||||
send(msg.createErrorReply(QDBusError::UnknownObject,
|
||||
QString::fromLatin1("No such object path '%1'").arg(msg.path())));
|
||||
QLatin1String("No such object path '%1'").arg(msg.path())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1551,8 +1552,8 @@ void QDBusConnectionPrivate::handleObjectCall(const QDBusMessage &msg)
|
||||
objThread = result.obj->thread();
|
||||
if (!objThread) {
|
||||
send(msg.createErrorReply(QDBusError::InternalError,
|
||||
QString::fromLatin1("Object '%1' (at path '%2')"
|
||||
" has no thread. Cannot deliver message.")
|
||||
QLatin1String("Object '%1' (at path '%2')"
|
||||
" has no thread. Cannot deliver message.")
|
||||
.arg(result.obj->objectName(), msg.path())));
|
||||
return;
|
||||
}
|
||||
@ -2082,7 +2083,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
|
||||
if (interface.isEmpty())
|
||||
interface = QLatin1String("<no-interface>");
|
||||
return QDBusMessage::createError(QDBusError::InternalError,
|
||||
QString::fromLatin1("Internal error trying to call %1.%2 at %3 (signature '%4'")
|
||||
QLatin1String("Internal error trying to call %1.%2 at %3 (signature '%4'")
|
||||
.arg(interface, message.member(),
|
||||
message.path(), message.signature()));
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const QString &interface_name)
|
||||
{
|
||||
return msg.createErrorReply(QDBusError::UnknownInterface,
|
||||
QString::fromLatin1("Interface %1 was not found in object %2")
|
||||
QLatin1String("Interface %1 was not found in object %2")
|
||||
.arg(interface_name, msg.path()));
|
||||
}
|
||||
|
||||
@ -211,10 +211,10 @@ static inline QDBusMessage
|
||||
propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name)
|
||||
{
|
||||
return msg.createErrorReply(QDBusError::UnknownProperty,
|
||||
QString::fromLatin1("Property %1%2%3 was not found in object %4")
|
||||
QLatin1String("Property %1%2%3 was not found in object %4")
|
||||
.arg(interface_name,
|
||||
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
|
||||
QString::fromLatin1(property_name),
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
QLatin1String(property_name),
|
||||
msg.path()));
|
||||
}
|
||||
|
||||
@ -302,16 +302,16 @@ static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &i
|
||||
return propertyNotFoundError(msg, interface_name, property_name);
|
||||
case PropertyTypeMismatch:
|
||||
return msg.createErrorReply(QDBusError::InvalidArgs,
|
||||
QString::fromLatin1("Invalid arguments for writing to property %1%2%3")
|
||||
QLatin1String("Invalid arguments for writing to property %1%2%3")
|
||||
.arg(interface_name,
|
||||
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
|
||||
QString::fromLatin1(property_name)));
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
QLatin1String(property_name)));
|
||||
case PropertyReadOnly:
|
||||
return msg.createErrorReply(QDBusError::PropertyReadOnly,
|
||||
QString::fromLatin1("Property %1%2%3 is read-only")
|
||||
QLatin1String("Property %1%2%3 is read-only")
|
||||
.arg(interface_name,
|
||||
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
|
||||
QString::fromLatin1(property_name)));
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
QLatin1String(property_name)));
|
||||
case PropertyWriteFailed:
|
||||
return msg.createErrorReply(QDBusError::InternalError,
|
||||
QString::fromLatin1("Internal error"));
|
||||
|
@ -211,7 +211,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
QMetaType::typeName(id), id);
|
||||
error(QString::fromLatin1("Unregistered type %1 passed in arguments")
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(QMetaType::typeName(id))));
|
||||
return false;
|
||||
}
|
||||
@ -253,7 +253,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginArray(int id)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
QMetaType::typeName(id), id);
|
||||
error(QString::fromLatin1("Unregistered type %1 passed in arguments")
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(QMetaType::typeName(id))));
|
||||
return this;
|
||||
}
|
||||
@ -268,14 +268,14 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
QMetaType::typeName(kid), kid);
|
||||
error(QString::fromLatin1("Unregistered type %1 passed in arguments")
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(QMetaType::typeName(kid))));
|
||||
return this;
|
||||
}
|
||||
if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) {
|
||||
qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
|
||||
QMetaType::typeName(kid), kid);
|
||||
error(QString::fromLatin1("Type %1 passed in arguments cannot be used as a key in a map")
|
||||
error(QLatin1String("Type %1 passed in arguments cannot be used as a key in a map")
|
||||
.arg(QLatin1String(QMetaType::typeName(kid))));
|
||||
return this;
|
||||
}
|
||||
@ -286,7 +286,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
typeName, vid);
|
||||
error(QString::fromLatin1("Unregistered type %1 passed in arguments")
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(typeName)));
|
||||
return this;
|
||||
}
|
||||
@ -417,7 +417,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
QMetaType::typeName(id), id);
|
||||
error(QString::fromLatin1("Unregistered type %1 passed in arguments")
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(QMetaType::typeName(id))));
|
||||
return false;
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
|
||||
|
||||
// mark as an error
|
||||
error = QDBusError(QDBusError::UnknownInterface,
|
||||
QString::fromLatin1("Interface '%1' was not found")
|
||||
QLatin1String("Interface '%1' was not found")
|
||||
.arg(interface));
|
||||
return 0;
|
||||
}
|
||||
|
@ -221,8 +221,8 @@ void QDBusPendingCallPrivate::checkReceivedSignature()
|
||||
|
||||
// can't use startsWith here because a null string doesn't start or end with an empty string
|
||||
if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {
|
||||
QString errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
|
||||
"expected \"%2\"");
|
||||
const auto errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
|
||||
"expected \"%2\"");
|
||||
replyMessage = QDBusMessage::createError(
|
||||
QDBusError::InvalidSignature,
|
||||
errorMsg.arg(replyMessage.signature(), expectedReplySignature));
|
||||
|
@ -228,14 +228,14 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
|
||||
receivedSignature = "<empty signature>";
|
||||
QString errorMsg;
|
||||
if (receivedType) {
|
||||
errorMsg = QString::fromLatin1("Unexpected reply signature: got \"%1\" (%4), "
|
||||
errorMsg = QLatin1String("Unexpected reply signature: got \"%1\" (%4), "
|
||||
"expected \"%2\" (%3)")
|
||||
.arg(QLatin1String(receivedSignature),
|
||||
QLatin1String(expectedSignature),
|
||||
QLatin1String(data.typeName()),
|
||||
QLatin1String(receivedType));
|
||||
} else {
|
||||
errorMsg = QString::fromLatin1("Unexpected reply signature: got \"%1\", "
|
||||
errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
|
||||
"expected \"%2\" (%3)")
|
||||
.arg(QLatin1String(receivedSignature),
|
||||
QLatin1String(expectedSignature),
|
||||
|
@ -106,7 +106,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
|
||||
return false;
|
||||
}
|
||||
if (isValidInterfaceName(name)) return true;
|
||||
*error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid interface class: %1").arg(name));
|
||||
*error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Invalid interface class: %1").arg(name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
|
||||
return false;
|
||||
}
|
||||
if (isValidBusName(name)) return true;
|
||||
*error = QDBusError(QDBusError::InvalidService, QString::fromLatin1("Invalid service name: %1").arg(name));
|
||||
*error = QDBusError(QDBusError::InvalidService, QLatin1String("Invalid service name: %1").arg(name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
|
||||
return false;
|
||||
}
|
||||
if (isValidObjectPath(path)) return true;
|
||||
*error = QDBusError(QDBusError::InvalidObjectPath, QString::fromLatin1("Invalid object path: %1").arg(path));
|
||||
*error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Invalid object path: %1").arg(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -143,8 +143,8 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
|
||||
return false;
|
||||
}
|
||||
if (isValidMemberName(name)) return true;
|
||||
*error = QDBusError(QDBusError::InvalidMember, QString::fromLatin1("Invalid %1 name: %2")
|
||||
.arg(QString::fromLatin1(nameType), name));
|
||||
*error = QDBusError(QDBusError::InvalidMember, QLatin1String("Invalid %1 name: %2")
|
||||
.arg(QLatin1String(nameType), name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
|
||||
return false;
|
||||
}
|
||||
if (isValidErrorName(name)) return true;
|
||||
*error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name));
|
||||
*error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Invalid error name: %1").arg(name));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,14 +108,14 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
if (!signature)
|
||||
continue;
|
||||
|
||||
retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
|
||||
retval += QLatin1String(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
|
||||
.arg(QLatin1String(mp.name()),
|
||||
QLatin1String(signature),
|
||||
accessAsString(mp.isReadable(), mp.isWritable()));
|
||||
|
||||
if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
|
||||
const char *typeName = QMetaType::typeName(typeId);
|
||||
retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
|
||||
retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
|
||||
.arg(typeNameToXml(typeName));
|
||||
} else {
|
||||
retval += QLatin1String("/>\n");
|
||||
@ -157,12 +157,12 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
if (typeId != QMetaType::UnknownType && typeId != QMetaType::Void) {
|
||||
const char *typeName = QDBusMetaType::typeToSignature(typeId);
|
||||
if (typeName) {
|
||||
xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n")
|
||||
xml += QLatin1String(" <arg type=\"%1\" direction=\"out\"/>\n")
|
||||
.arg(typeNameToXml(typeName));
|
||||
|
||||
// do we need to describe this argument?
|
||||
if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid)
|
||||
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
|
||||
xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
|
||||
.arg(typeNameToXml(QMetaType::typeName(typeId)));
|
||||
} else {
|
||||
qWarning() << "Unsupported return type" << typeId << QMetaType::typeName(typeId) << "in method" << mm.name();
|
||||
@ -199,7 +199,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
|
||||
QString name;
|
||||
if (!names.at(j - 1).isEmpty())
|
||||
name = QString::fromLatin1("name=\"%1\" ").arg(QLatin1String(names.at(j - 1)));
|
||||
name = QLatin1String("name=\"%1\" ").arg(QLatin1String(names.at(j - 1)));
|
||||
|
||||
bool isOutput = isSignal || j > inputCount;
|
||||
|
||||
@ -233,7 +233,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
" value=\"true\"/>\n");
|
||||
|
||||
retval += xml;
|
||||
retval += QString::fromLatin1(" </%1>\n")
|
||||
retval += QLatin1String(" </%1>\n")
|
||||
.arg(isSignal ? QLatin1String("signal") : QLatin1String("method"));
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
|
||||
|
||||
if (xml.isEmpty())
|
||||
return QString(); // don't add an empty interface
|
||||
return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n")
|
||||
return QLatin1String(" <interface name=\"%1\">\n%2 </interface>\n")
|
||||
.arg(interface, xml);
|
||||
}
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user