summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2015-10-18 15:14:33 +0100
committerSérgio Martins <sergio.martins@kdab.com>2015-10-18 23:12:14 +0000
commit4867a49618e0d6a476e0549aeca5134b2e3c5892 (patch)
tree769bb64015acaa22e9c86d90cff4093877fc0ead
parent35fa7aed1db1157a7189ff271ebd241ebe04d2cc (diff)
Use QStringRef in a bunch of places.wip/dbus
Done automatically with clazy static analyzer. Change-Id: Ia0cf8fa24331ab102a3c3c30c2aa92ef1ba772e2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp2
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp2
-rw-r--r--src/qml/qml/qqmlstringconverters.cpp16
-rw-r--r--src/quick/items/qquicktextcontrol.cpp2
-rw-r--r--src/quick/items/qquicktextinput.cpp6
-rw-r--r--src/quick/util/qquickglobal.cpp10
-rw-r--r--tools/qmlmin/main.cpp2
7 files changed, 20 insertions, 20 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index bfbeef5856..513aedd568 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -342,7 +342,7 @@ void QQmlDebugServerImpl::parseArguments()
for (; argsIt != argsItEnd; ++argsIt) {
const QString strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
- portFrom = strArgument.mid(5).toInt(&ok);
+ portFrom = strArgument.midRef(5).toInt(&ok);
portTo = portFrom;
QStringList::const_iterator argsNext = argsIt + 1;
if (argsNext == argsItEnd)
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 110a2c9089..b4733356ac 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -302,7 +302,7 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
++r;
}
if (*r)
- output.append(input.mid(start, i - start + 1));
+ output.append(input.midRef(start, i - start + 1));
else
output.append(QChar(b));
} else {
diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp
index eb0afda927..6a5c0736cf 100644
--- a/src/qml/qml/qqmlstringconverters.cpp
+++ b/src/qml/qml/qqmlstringconverters.cpp
@@ -137,8 +137,8 @@ QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
bool xGood, yGood;
int index = s.indexOf(QLatin1Char(','));
- qreal xCoord = s.left(index).toDouble(&xGood);
- qreal yCoord = s.mid(index+1).toDouble(&yGood);
+ qreal xCoord = s.leftRef(index).toDouble(&xGood);
+ qreal yCoord = s.midRef(index+1).toDouble(&yGood);
if (!xGood || !yGood) {
if (ok)
*ok = false;
@@ -161,8 +161,8 @@ QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)
bool wGood, hGood;
int index = s.indexOf(QLatin1Char('x'));
- qreal width = s.left(index).toDouble(&wGood);
- qreal height = s.mid(index+1).toDouble(&hGood);
+ qreal width = s.leftRef(index).toDouble(&wGood);
+ qreal height = s.midRef(index+1).toDouble(&hGood);
if (!wGood || !hGood) {
if (ok)
*ok = false;
@@ -185,12 +185,12 @@ QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)
bool xGood, yGood, wGood, hGood;
int index = s.indexOf(QLatin1Char(','));
- qreal x = s.left(index).toDouble(&xGood);
+ qreal x = s.leftRef(index).toDouble(&xGood);
int index2 = s.indexOf(QLatin1Char(','), index+1);
- qreal y = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal y = s.midRef(index+1, index2-index-1).toDouble(&yGood);
index = s.indexOf(QLatin1Char('x'), index2+1);
- qreal width = s.mid(index2+1, index-index2-1).toDouble(&wGood);
- qreal height = s.mid(index+1).toDouble(&hGood);
+ qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood);
+ qreal height = s.midRef(index+1).toDouble(&hGood);
if (!xGood || !yGood || !wGood || !hGood) {
if (ok)
*ok = false;
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 04e43c017e..d0678b4278 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -1419,7 +1419,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVar
tmpCursor.movePosition(QTextCursor::NextBlock);
--numBlocks;
}
- result += block.text().mid(0,localPos);
+ result += block.text().midRef(0,localPos);
return QVariant(result);
}
default:
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index ab8e75bfef..5b7a52f1aa 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -3533,7 +3533,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
int remaining = m_maxLength - m_text.length();
if (remaining != 0) {
m_text.insert(m_cursor, s.left(remaining));
- for (int i = 0; i < (int) s.left(remaining).length(); ++i)
+ for (int i = 0; i < (int) s.leftRef(remaining).length(); ++i)
addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1));
m_textDirty = true;
}
@@ -3886,14 +3886,14 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
int n = findInMask(i, true, true, str[(int)strIndex]);
if (n != -1) {
if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) {
- s += fill.mid(i, n-i+1);
+ s += fill.midRef(i, n-i+1);
i = n + 1; // update i to find + 1
}
} else {
// search for valid m_blank if not
n = findInMask(i, true, false, str[(int)strIndex]);
if (n != -1) {
- s += fill.mid(i, n-i);
+ s += fill.midRef(i, n-i);
switch (m_maskData[n].caseMode) {
case MaskInputData::Upper:
s += str[(int)strIndex].toUpper();
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 25dd09c01f..3cb7cc3b7f 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -231,10 +231,10 @@ public:
int index3 = s.indexOf(QLatin1Char(','), index2+1);
bool sGood, xGood, yGood, zGood;
- qreal sCoord = s.left(index).toDouble(&sGood);
- qreal xCoord = s.mid(index+1, index2-index-1).toDouble(&xGood);
- qreal yCoord = s.mid(index2+1, index3-index2-1).toDouble(&yGood);
- qreal zCoord = s.mid(index3+1).toDouble(&zGood);
+ qreal sCoord = s.leftRef(index).toDouble(&sGood);
+ qreal xCoord = s.midRef(index+1, index2-index-1).toDouble(&xGood);
+ qreal yCoord = s.midRef(index2+1, index3-index2-1).toDouble(&yGood);
+ qreal zCoord = s.midRef(index3+1).toDouble(&zGood);
if (sGood && xGood && yGood && zGood) {
if (ok) *ok = true;
@@ -254,7 +254,7 @@ public:
QString mutableStr = s;
for (int i = 0; vOK && i < 16; ++i) {
int cidx = mutableStr.indexOf(QLatin1Char(','));
- matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
+ matValues[i] = mutableStr.leftRef(cidx).toDouble(&vOK);
mutableStr = mutableStr.mid(cidx + 1);
}
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index a3f2b92bde..82fdb92801 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -590,7 +590,7 @@ int runQmlmin(int argc, char *argv[])
}
} else if (arg.startsWith(QLatin1String("-w"))) {
bool ok;
- width = arg.mid(2).toInt(&ok);
+ width = arg.midRef(2).toInt(&ok);
if (!ok) {
std::cerr << "qmlmin: argument to '-w' is invalid" << std::endl;