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

@@ -92,7 +92,7 @@ QString BbMediaStorageLocation::generateFileName(const QString &prefix, const QD
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

@@ -587,8 +587,8 @@ void MmRendererMediaPlayerControl::setMmBufferStatus(const QString &bufferStatus
{
const int slashPos = bufferStatus.indexOf('/');
if (slashPos != -1) {
const int fill = bufferStatus.left(slashPos).toInt();
const int capacity = bufferStatus.mid(slashPos + 1).toInt();
const int fill = bufferStatus.leftRef(slashPos).toInt();
const int capacity = bufferStatus.midRef(slashPos + 1).toInt();
if (capacity != 0) {
m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f;
emit bufferStatusChanged(m_bufferStatus);

View File

@@ -97,8 +97,8 @@ bool MmRendererMetaData::parse(const QString &contextName)
const int separatorPos = line.indexOf(separator);
if (separatorPos != -1) {
const QString key = line.left(separatorPos);
const QString value = line.mid(separatorPos + separator.length());
const QStringRef key = line.left(separatorPos);
const QStringRef value = line.mid(separatorPos + separator.length());
if (key == durationKey)
m_duration = value.toLongLong();
@@ -113,15 +113,15 @@ bool MmRendererMetaData::parse(const QString &contextName)
else if (key == pixelHeightKey)
m_pixelHeight = value.toFloat();
else if (key == titleKey)
m_title = value;
m_title = value.toString();
else if (key == seekableKey)
m_seekable = !(value == QLatin1String("0"));
else if (key == artistKey)
m_artist = value;
m_artist = value.toString();
else if (key == commentKey)
m_comment = value;
m_comment = value.toString();
else if (key == genreKey)
m_genre = value;
m_genre = value.toString();
else if (key == yearKey)
m_year = value.toInt();
else if (key == bitRateKey)
@@ -129,7 +129,7 @@ bool MmRendererMetaData::parse(const QString &contextName)
else if (key == sampleKey)
m_sampleRate = value.toInt();
else if (key == albumKey)
m_album = value;
m_album = value.toString();
else if (key == trackKey)
m_track = value.toInt();
}