From f530942fe4733d9002286aa1561a08a989630f28 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 1 Oct 2013 23:04:47 +0200 Subject: 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 --- src/dbus/qdbusxmlgenerator.cpp | 17 +++++++++-------- 1 file 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("