Preferably use QStringRef::toInt().

Avoid allocations for converting to int.

Change-Id: Id8c79334f4809ec075ffe7e6b7635be4873eafd8
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Friedemann Kleint
2016-02-03 13:49:53 +01:00
parent 30b1e70c42
commit 97af238656
24 changed files with 31 additions and 31 deletions

View File

@@ -108,8 +108,8 @@ void TypeDescriptionReader::readDocument(UiProgram *ast)
const QString versionString = _source.mid(import->versionToken.offset, import->versionToken.length);
const int dotIdx = versionString.indexOf(QLatin1Char('.'));
if (dotIdx != -1) {
version = ComponentVersion(versionString.left(dotIdx).toInt(),
versionString.mid(dotIdx + 1).toInt());
version = ComponentVersion(versionString.leftRef(dotIdx).toInt(),
versionString.midRef(dotIdx + 1).toInt());
}
if (version.majorVersion() != 1) {
addError(import->versionToken, tr("Major version different from 1 not supported."));

View File

@@ -79,7 +79,7 @@ QColor QmlJS::toQColor(const QString &qmlColorString)
QColor color;
if (qmlColorString.size() == 9 && qmlColorString.at(0) == QLatin1Char('#')) {
bool ok;
const int alpha = qmlColorString.mid(1, 2).toInt(&ok, 16);
const int alpha = qmlColorString.midRef(1, 2).toInt(&ok, 16);
if (ok) {
QString name(qmlColorString.at(0));
name.append(qmlColorString.right(6));