diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-03-31 15:03:12 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-28 16:47:54 +0000 |
commit | c8e4d15004bade8b99aaf74b6f899911b5d66962 (patch) | |
tree | 60b1e412cebe52042e1e2c00302f7f61ee3cb699 /src/dbus/qdbusconnection.cpp | |
parent | 6ebe7e8f37731a07ca7b1d5b8b93ccf73fb0273b (diff) | |
download | qtbase-c8e4d15004bade8b99aaf74b6f899911b5d66962.tar.gz |
DBus: use QStringRef to optimize memory allocation
Replace substring functions that return QString with
corresponding functions that return QStringRef where
it's possible.
Create QString from QStringRef only where necessary.
Add overloaded functions with QStringRef arg
in QDBusUtil:
- isValidUniqueConnectionName()
- isValidMemberName()
- isValidPartOfObjectPath()
Change-Id: I4a24a298702728ba7d3a65c39e25c3a9c759e07f
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/dbus/qdbusconnection.cpp')
-rw-r--r-- | src/dbus/qdbusconnection.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index ea8c2b0311..cddb7dfb95 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -44,6 +44,7 @@ #include <qdebug.h> #include <qcoreapplication.h> #include <qstringlist.h> +#include <qvector.h> #include <qtimer.h> #include <qthread.h> @@ -909,8 +910,8 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path)) return false; - QStringList pathComponents = path.split(QLatin1Char('/')); - if (pathComponents.last().isEmpty()) + auto pathComponents = path.splitRef(QLatin1Char('/')); + if (pathComponents.constLast().isEmpty()) pathComponents.removeLast(); QDBusWriteLocker locker(RegisterObjectAction, d); @@ -965,7 +966,7 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa } } else { // add entry - node = node->children.insert(it, pathComponents.at(i)); + node = node->children.insert(it, pathComponents.at(i).toString()); } // iterate @@ -1017,8 +1018,8 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path)) return 0; - QStringList pathComponents = path.split(QLatin1Char('/')); - if (pathComponents.last().isEmpty()) + auto pathComponents = path.splitRef(QLatin1Char('/')); + if (pathComponents.constLast().isEmpty()) pathComponents.removeLast(); // lower-bound search for where this object should enter in the tree |