Use QStringRef in a bunch of places.
Done automatically with clazy static analyzer. Change-Id: Ia0cf8fa24331ab102a3c3c30c2aa92ef1ba772e2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
parent
35fa7aed1d
commit
4867a49618
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue