aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_server
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-06 15:23:58 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-26 10:31:19 +0000
commit1be53f4e143d417d60cd1f9a292193dab59b5b20 (patch)
treeefc9f54af4d646d9e7d5618e3c2688d9442bbc71 /src/plugins/qmltooling/qmldbg_server
parent84f61dd2d2b0140814b39a2c5238a6e31c49abd7 (diff)
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. While touching the code, also port loops to C++11 style. Change-Id: I04c99b24ea6afd3715e3edf9ea00bfab838fd53c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_server')
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 28213e7b56..a6d93e85ae 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -53,6 +53,7 @@
#include <QtCore/QDir>
#include <QtCore/QPluginLoader>
#include <QtCore/QStringList>
+#include <QtCore/QVector>
#include <QtCore/qwaitcondition.h>
QT_BEGIN_NAMESPACE
@@ -345,40 +346,40 @@ void QQmlDebugServerImpl::parseArguments()
QString fileName;
QStringList services;
- const QStringList lstjsDebugArguments = args.split(QLatin1Char(','));
- QStringList::const_iterator argsItEnd = lstjsDebugArguments.cend();
- QStringList::const_iterator argsIt = lstjsDebugArguments.cbegin();
- for (; argsIt != argsItEnd; ++argsIt) {
- const QString strArgument = *argsIt;
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','));
+ for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
+ const QStringRef &strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
- portFrom = strArgument.midRef(5).toInt(&ok);
+ portFrom = strArgument.mid(5).toInt(&ok);
portTo = portFrom;
- QStringList::const_iterator argsNext = argsIt + 1;
+ const auto argsNext = argsIt + 1;
if (argsNext == argsItEnd)
break;
- const QString nextArgument = *argsNext;
-
- // Don't use QStringLiteral here. QRegExp has a global cache and will save an implicitly
- // shared copy of the passed string. That copy isn't properly detached when the library
- // is unloaded if the original string lives in the library's .rodata
- if (ok && nextArgument.contains(QRegExp(QLatin1String("^\\s*\\d+\\s*$")))) {
- portTo = nextArgument.toInt(&ok);
- ++argsIt;
+ if (ok) {
+ const QString nextArgument = argsNext->toString();
+
+ // Don't use QStringLiteral here. QRegExp has a global cache and will save an implicitly
+ // shared copy of the passed string. That copy isn't properly detached when the library
+ // is unloaded if the original string lives in the library's .rodata
+ if (nextArgument.contains(QRegExp(QLatin1String("^\\s*\\d+\\s*$")))) {
+ portTo = nextArgument.toInt(&ok);
+ ++argsIt;
+ }
}
} else if (strArgument.startsWith(QLatin1String("host:"))) {
- hostAddress = strArgument.mid(5);
+ hostAddress = strArgument.mid(5).toString();
} else if (strArgument == QLatin1String("block")) {
block = true;
} else if (strArgument.startsWith(QLatin1String("file:"))) {
- fileName = strArgument.mid(5);
+ fileName = strArgument.mid(5).toString();
ok = !fileName.isEmpty();
} else if (strArgument.startsWith(QLatin1String("services:"))) {
- services.append(strArgument.mid(9));
+ services.append(strArgument.mid(9).toString());
} else if (!services.isEmpty()) {
- services.append(strArgument);
+ services.append(strArgument.toString());
} else {
const QString message = tr("QML Debugger: Invalid argument \"%1\" detected."
- " Ignoring the same.").arg(strArgument);
+ " Ignoring the same.").arg(strArgument.toString());
qWarning("%s", qPrintable(message));
}
}