diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2013-10-01 23:04:47 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-14 00:34:25 +0100 |
commit | f530942fe4733d9002286aa1561a08a989630f28 (patch) | |
tree | 0d0e7b5a6e847b8a6a9c1d184647994e00c1ab6e /src/dbus | |
parent | 2223cc8a2d91968951432f337fa4737cf792d514 (diff) |
QDBus: avoid relocations
Instead of using Q_STRINGTABLE, use a switch/if construct
to be able to share the string data for "write" and "readwrite".
Change-Id: Ia1c7b8a0f13a809372de2e5a956978dc2d569e92
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusxmlgenerator.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index c724ac573a..fc8b84c889 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -77,6 +77,14 @@ static inline QString typeNameToXml(const char *typeName) return rich; } +static inline QLatin1String accessAsString(bool read, bool write) +{ + if (read) + return write ? QLatin1String("readwrite") : QLatin1String("read") ; + else + return write ? QLatin1String("write") : QLatin1String("") ; +} + // implement the D-Bus org.freedesktop.DBus.Introspectable interface // we do that by analysing the metaObject of all the adaptor interfaces @@ -88,7 +96,6 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method if (flags & (QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportNonScriptableProperties)) { for (int i = propOffset; i < mo->propertyCount(); ++i) { - static const char *accessvalues[] = {0, "read", "write", "readwrite"}; QMetaProperty mp = mo->property(i); @@ -96,12 +103,6 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method (!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties)))) continue; - int access = 0; - if (mp.isReadable()) - access |= 1; - if (mp.isWritable()) - access |= 2; - int typeId = mp.userType(); if (!typeId) continue; @@ -112,7 +113,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"") .arg(QLatin1String(mp.name())) .arg(QLatin1String(signature)) - .arg(QLatin1String(accessvalues[access])); + .arg(accessAsString(mp.isReadable(), mp.isWritable())); if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { const char *typeName = QMetaType::typeName(typeId); |