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) {
|
for (; argsIt != argsItEnd; ++argsIt) {
|
||||||
const QString strArgument = *argsIt;
|
const QString strArgument = *argsIt;
|
||||||
if (strArgument.startsWith(QLatin1String("port:"))) {
|
if (strArgument.startsWith(QLatin1String("port:"))) {
|
||||||
portFrom = strArgument.mid(5).toInt(&ok);
|
portFrom = strArgument.midRef(5).toInt(&ok);
|
||||||
portTo = portFrom;
|
portTo = portFrom;
|
||||||
QStringList::const_iterator argsNext = argsIt + 1;
|
QStringList::const_iterator argsNext = argsIt + 1;
|
||||||
if (argsNext == argsItEnd)
|
if (argsNext == argsItEnd)
|
||||||
|
|
|
@ -302,7 +302,7 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
|
||||||
++r;
|
++r;
|
||||||
}
|
}
|
||||||
if (*r)
|
if (*r)
|
||||||
output.append(input.mid(start, i - start + 1));
|
output.append(input.midRef(start, i - start + 1));
|
||||||
else
|
else
|
||||||
output.append(QChar(b));
|
output.append(QChar(b));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,8 +137,8 @@ QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool xGood, yGood;
|
bool xGood, yGood;
|
||||||
int index = s.indexOf(QLatin1Char(','));
|
int index = s.indexOf(QLatin1Char(','));
|
||||||
qreal xCoord = s.left(index).toDouble(&xGood);
|
qreal xCoord = s.leftRef(index).toDouble(&xGood);
|
||||||
qreal yCoord = s.mid(index+1).toDouble(&yGood);
|
qreal yCoord = s.midRef(index+1).toDouble(&yGood);
|
||||||
if (!xGood || !yGood) {
|
if (!xGood || !yGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
@ -161,8 +161,8 @@ QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool wGood, hGood;
|
bool wGood, hGood;
|
||||||
int index = s.indexOf(QLatin1Char('x'));
|
int index = s.indexOf(QLatin1Char('x'));
|
||||||
qreal width = s.left(index).toDouble(&wGood);
|
qreal width = s.leftRef(index).toDouble(&wGood);
|
||||||
qreal height = s.mid(index+1).toDouble(&hGood);
|
qreal height = s.midRef(index+1).toDouble(&hGood);
|
||||||
if (!wGood || !hGood) {
|
if (!wGood || !hGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
@ -185,12 +185,12 @@ QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool xGood, yGood, wGood, hGood;
|
bool xGood, yGood, wGood, hGood;
|
||||||
int index = s.indexOf(QLatin1Char(','));
|
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);
|
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);
|
index = s.indexOf(QLatin1Char('x'), index2+1);
|
||||||
qreal width = s.mid(index2+1, index-index2-1).toDouble(&wGood);
|
qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood);
|
||||||
qreal height = s.mid(index+1).toDouble(&hGood);
|
qreal height = s.midRef(index+1).toDouble(&hGood);
|
||||||
if (!xGood || !yGood || !wGood || !hGood) {
|
if (!xGood || !yGood || !wGood || !hGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
|
|
@ -1419,7 +1419,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVar
|
||||||
tmpCursor.movePosition(QTextCursor::NextBlock);
|
tmpCursor.movePosition(QTextCursor::NextBlock);
|
||||||
--numBlocks;
|
--numBlocks;
|
||||||
}
|
}
|
||||||
result += block.text().mid(0,localPos);
|
result += block.text().midRef(0,localPos);
|
||||||
return QVariant(result);
|
return QVariant(result);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3533,7 +3533,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
|
||||||
int remaining = m_maxLength - m_text.length();
|
int remaining = m_maxLength - m_text.length();
|
||||||
if (remaining != 0) {
|
if (remaining != 0) {
|
||||||
m_text.insert(m_cursor, s.left(remaining));
|
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));
|
addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1));
|
||||||
m_textDirty = true;
|
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]);
|
int n = findInMask(i, true, true, str[(int)strIndex]);
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) {
|
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
|
i = n + 1; // update i to find + 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// search for valid m_blank if not
|
// search for valid m_blank if not
|
||||||
n = findInMask(i, true, false, str[(int)strIndex]);
|
n = findInMask(i, true, false, str[(int)strIndex]);
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
s += fill.mid(i, n-i);
|
s += fill.midRef(i, n-i);
|
||||||
switch (m_maskData[n].caseMode) {
|
switch (m_maskData[n].caseMode) {
|
||||||
case MaskInputData::Upper:
|
case MaskInputData::Upper:
|
||||||
s += str[(int)strIndex].toUpper();
|
s += str[(int)strIndex].toUpper();
|
||||||
|
|
|
@ -231,10 +231,10 @@ public:
|
||||||
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
||||||
|
|
||||||
bool sGood, xGood, yGood, zGood;
|
bool sGood, xGood, yGood, zGood;
|
||||||
qreal sCoord = s.left(index).toDouble(&sGood);
|
qreal sCoord = s.leftRef(index).toDouble(&sGood);
|
||||||
qreal xCoord = s.mid(index+1, index2-index-1).toDouble(&xGood);
|
qreal xCoord = s.midRef(index+1, index2-index-1).toDouble(&xGood);
|
||||||
qreal yCoord = s.mid(index2+1, index3-index2-1).toDouble(&yGood);
|
qreal yCoord = s.midRef(index2+1, index3-index2-1).toDouble(&yGood);
|
||||||
qreal zCoord = s.mid(index3+1).toDouble(&zGood);
|
qreal zCoord = s.midRef(index3+1).toDouble(&zGood);
|
||||||
|
|
||||||
if (sGood && xGood && yGood && zGood) {
|
if (sGood && xGood && yGood && zGood) {
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
|
@ -254,7 +254,7 @@ public:
|
||||||
QString mutableStr = s;
|
QString mutableStr = s;
|
||||||
for (int i = 0; vOK && i < 16; ++i) {
|
for (int i = 0; vOK && i < 16; ++i) {
|
||||||
int cidx = mutableStr.indexOf(QLatin1Char(','));
|
int cidx = mutableStr.indexOf(QLatin1Char(','));
|
||||||
matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
|
matValues[i] = mutableStr.leftRef(cidx).toDouble(&vOK);
|
||||||
mutableStr = mutableStr.mid(cidx + 1);
|
mutableStr = mutableStr.mid(cidx + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -590,7 +590,7 @@ int runQmlmin(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
} else if (arg.startsWith(QLatin1String("-w"))) {
|
} else if (arg.startsWith(QLatin1String("-w"))) {
|
||||||
bool ok;
|
bool ok;
|
||||||
width = arg.mid(2).toInt(&ok);
|
width = arg.midRef(2).toInt(&ok);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "qmlmin: argument to '-w' is invalid" << std::endl;
|
std::cerr << "qmlmin: argument to '-w' is invalid" << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue