Use QStringRef instead of QString whenever possible.

That way we reduce count of temporary QString instances.

Change-Id: Id806c68ea616828c2355c07b8576616fa6a8da17
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Jędrzej Nowacki
2014-01-15 16:56:12 +01:00
committed by The Qt Project
parent 15025088ea
commit e485e066ac
11 changed files with 23 additions and 23 deletions

View File

@@ -103,7 +103,7 @@ QString QAndroidMediaStorageLocation::generateFileName(const QString &prefix,
if (lastMediaIndex == 0) {
// first run, find the maximum media number during the fist capture
Q_FOREACH (const QString &fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(extension))) {
const qint64 mediaIndex = fileName.mid(prefix.length(), fileName.size() - prefix.length() - extension.length() - 1).toInt();
const qint64 mediaIndex = fileName.midRef(prefix.length(), fileName.size() - prefix.length() - extension.length() - 1).toInt();
lastMediaIndex = qMax(lastMediaIndex, mediaIndex);
}
}

View File

@@ -183,7 +183,7 @@ void QAndroidMetaDataReaderControl::updateData()
// The genre can be returned as an ID3v2 id, get the name for it in that case
if (string.startsWith('(') && string.endsWith(')')) {
bool ok = false;
int genreId = string.mid(1, string.length() - 2).toInt(&ok);
int genreId = string.midRef(1, string.length() - 2).toInt(&ok);
if (ok && genreId >= 0 && genreId <= 125)
string = QLatin1String(qt_ID3GenreNames[genreId]);
}