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:
committed by
The Qt Project
parent
15025088ea
commit
e485e066ac
@@ -100,7 +100,7 @@ public:
|
|||||||
m_extraInfo.clear();
|
m_extraInfo.clear();
|
||||||
int artistStart = line.indexOf(QLatin1String(","), 8);
|
int artistStart = line.indexOf(QLatin1String(","), 8);
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int length = line.mid(8, artistStart < 8 ? -1 : artistStart - 8).trimmed().toInt(&ok);
|
int length = line.midRef(8, artistStart < 8 ? -1 : artistStart - 8).trimmed().toInt(&ok);
|
||||||
if (ok && length > 0) {
|
if (ok && length > 0) {
|
||||||
//convert from second to milisecond
|
//convert from second to milisecond
|
||||||
m_extraInfo[QMediaMetaData::Duration] = QVariant(length * 1000);
|
m_extraInfo[QMediaMetaData::Duration] = QVariant(length * 1000);
|
||||||
@@ -108,13 +108,13 @@ public:
|
|||||||
if (artistStart > 0) {
|
if (artistStart > 0) {
|
||||||
int titleStart = getSplitIndex(line, artistStart);
|
int titleStart = getSplitIndex(line, artistStart);
|
||||||
if (titleStart > artistStart) {
|
if (titleStart > artistStart) {
|
||||||
m_extraInfo[QMediaMetaData::Author] = line.mid(artistStart + 1,
|
m_extraInfo[QMediaMetaData::Author] = line.midRef(artistStart + 1,
|
||||||
titleStart - artistStart - 1).trimmed().
|
titleStart - artistStart - 1).trimmed().toString().
|
||||||
replace(QLatin1String("--"), QLatin1String("-"));
|
replace(QLatin1String("--"), QLatin1String("-"));
|
||||||
m_extraInfo[QMediaMetaData::Title] = line.mid(titleStart + 1).trimmed().
|
m_extraInfo[QMediaMetaData::Title] = line.midRef(titleStart + 1).trimmed().toString().
|
||||||
replace(QLatin1String("--"), QLatin1String("-"));
|
replace(QLatin1String("--"), QLatin1String("-"));
|
||||||
} else {
|
} else {
|
||||||
m_extraInfo[QMediaMetaData::Title] = line.mid(artistStart + 1).trimmed().
|
m_extraInfo[QMediaMetaData::Title] = line.midRef(artistStart + 1).trimmed().toString().
|
||||||
replace(QLatin1String("--"), QLatin1String("-"));
|
replace(QLatin1String("--"), QLatin1String("-"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ Version=2
|
|||||||
emit error(QPlaylistFileParser::FormatError, QString(tr("Error parsing playlist at line[%1]:%2")).arg(QString::number(lineIndex), line));
|
emit error(QPlaylistFileParser::FormatError, QString(tr("Error parsing playlist at line[%1]:%2")).arg(QString::number(lineIndex), line));
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
return line.mid(start + 1).trimmed();
|
return line.midRef(start + 1).trimmed().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCount(int count) {
|
void setCount(int count) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ QString QAndroidMediaStorageLocation::generateFileName(const QString &prefix,
|
|||||||
if (lastMediaIndex == 0) {
|
if (lastMediaIndex == 0) {
|
||||||
// first run, find the maximum media number during the fist capture
|
// 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))) {
|
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);
|
lastMediaIndex = qMax(lastMediaIndex, mediaIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ void QAndroidMetaDataReaderControl::updateData()
|
|||||||
// The genre can be returned as an ID3v2 id, get the name for it in that case
|
// The genre can be returned as an ID3v2 id, get the name for it in that case
|
||||||
if (string.startsWith('(') && string.endsWith(')')) {
|
if (string.startsWith('(') && string.endsWith(')')) {
|
||||||
bool ok = false;
|
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)
|
if (ok && genreId >= 0 && genreId <= 125)
|
||||||
string = QLatin1String(qt_ID3GenreNames[genreId]);
|
string = QLatin1String(qt_ID3GenreNames[genreId]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ QString AudioCaptureSession::generateFileName(const QDir &dir,
|
|||||||
{
|
{
|
||||||
int lastClip = 0;
|
int lastClip = 0;
|
||||||
foreach(QString fileName, dir.entryList(QStringList() << QString("clip_*.%1").arg(ext))) {
|
foreach(QString fileName, dir.entryList(QStringList() << QString("clip_*.%1").arg(ext))) {
|
||||||
int imgNumber = fileName.mid(5, fileName.size()-6-ext.length()).toInt();
|
int imgNumber = fileName.midRef(5, fileName.size()-6-ext.length()).toInt();
|
||||||
lastClip = qMax(lastClip, imgNumber);
|
lastClip = qMax(lastClip, imgNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ QString AVFStorageLocation::generateFileName(const QString &prefix, const QDir &
|
|||||||
if (lastClip == 0) {
|
if (lastClip == 0) {
|
||||||
//first run, find the maximum clip number during the fist capture
|
//first run, find the maximum clip number during the fist capture
|
||||||
Q_FOREACH (const QString &fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(ext))) {
|
Q_FOREACH (const QString &fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(ext))) {
|
||||||
int imgNumber = fileName.mid(prefix.length(), fileName.size()-prefix.length()-ext.length()-1).toInt();
|
int imgNumber = fileName.midRef(prefix.length(), fileName.size()-prefix.length()-ext.length()-1).toInt();
|
||||||
lastClip = qMax(lastClip, imgNumber);
|
lastClip = qMax(lastClip, imgNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ QString CameraBinSession::generateFileName(const QString &prefix, const QDir &di
|
|||||||
{
|
{
|
||||||
int lastClip = 0;
|
int lastClip = 0;
|
||||||
foreach(QString fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(ext))) {
|
foreach(QString fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(ext))) {
|
||||||
int imgNumber = fileName.mid(prefix.length(), fileName.size()-prefix.length()-ext.length()-1).toInt();
|
int imgNumber = fileName.midRef(prefix.length(), fileName.size()-prefix.length()-ext.length()-1).toInt();
|
||||||
lastClip = qMax(lastClip, imgNumber);
|
lastClip = qMax(lastClip, imgNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ int QGstreamerImageCaptureControl::capture(const QString &fileName)
|
|||||||
int lastImage = 0;
|
int lastImage = 0;
|
||||||
QDir outputDir = QDir::currentPath();
|
QDir outputDir = QDir::currentPath();
|
||||||
foreach(QString fileName, outputDir.entryList(QStringList() << "img_*.jpg")) {
|
foreach(QString fileName, outputDir.entryList(QStringList() << "img_*.jpg")) {
|
||||||
int imgNumber = fileName.mid(4, fileName.size()-8).toInt();
|
int imgNumber = fileName.midRef(4, fileName.size()-8).toInt();
|
||||||
lastImage = qMax(lastImage, imgNumber);
|
lastImage = qMax(lastImage, imgNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ QString QGstreamerRecorderControl::generateFileName(const QDir &dir, const QStri
|
|||||||
|
|
||||||
int lastClip = 0;
|
int lastClip = 0;
|
||||||
foreach(QString fileName, dir.entryList(QStringList() << QString("clip_*.%1").arg(ext))) {
|
foreach(QString fileName, dir.entryList(QStringList() << QString("clip_*.%1").arg(ext))) {
|
||||||
int imgNumber = fileName.mid(5, fileName.size()-6-ext.length()).toInt();
|
int imgNumber = fileName.midRef(5, fileName.size()-6-ext.length()).toInt();
|
||||||
lastClip = qMax(lastClip, imgNumber);
|
lastClip = qMax(lastClip, imgNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ QString BbMediaStorageLocation::generateFileName(const QString &prefix, const QD
|
|||||||
if (lastMediaIndex == 0) {
|
if (lastMediaIndex == 0) {
|
||||||
// first run, find the maximum media number during the fist capture
|
// 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))) {
|
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);
|
lastMediaIndex = qMax(lastMediaIndex, mediaIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -587,8 +587,8 @@ void MmRendererMediaPlayerControl::setMmBufferStatus(const QString &bufferStatus
|
|||||||
{
|
{
|
||||||
const int slashPos = bufferStatus.indexOf('/');
|
const int slashPos = bufferStatus.indexOf('/');
|
||||||
if (slashPos != -1) {
|
if (slashPos != -1) {
|
||||||
const int fill = bufferStatus.left(slashPos).toInt();
|
const int fill = bufferStatus.leftRef(slashPos).toInt();
|
||||||
const int capacity = bufferStatus.mid(slashPos + 1).toInt();
|
const int capacity = bufferStatus.midRef(slashPos + 1).toInt();
|
||||||
if (capacity != 0) {
|
if (capacity != 0) {
|
||||||
m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f;
|
m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f;
|
||||||
emit bufferStatusChanged(m_bufferStatus);
|
emit bufferStatusChanged(m_bufferStatus);
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ bool MmRendererMetaData::parse(const QString &contextName)
|
|||||||
|
|
||||||
const int separatorPos = line.indexOf(separator);
|
const int separatorPos = line.indexOf(separator);
|
||||||
if (separatorPos != -1) {
|
if (separatorPos != -1) {
|
||||||
const QString key = line.left(separatorPos);
|
const QStringRef key = line.left(separatorPos);
|
||||||
const QString value = line.mid(separatorPos + separator.length());
|
const QStringRef value = line.mid(separatorPos + separator.length());
|
||||||
|
|
||||||
if (key == durationKey)
|
if (key == durationKey)
|
||||||
m_duration = value.toLongLong();
|
m_duration = value.toLongLong();
|
||||||
@@ -113,15 +113,15 @@ bool MmRendererMetaData::parse(const QString &contextName)
|
|||||||
else if (key == pixelHeightKey)
|
else if (key == pixelHeightKey)
|
||||||
m_pixelHeight = value.toFloat();
|
m_pixelHeight = value.toFloat();
|
||||||
else if (key == titleKey)
|
else if (key == titleKey)
|
||||||
m_title = value;
|
m_title = value.toString();
|
||||||
else if (key == seekableKey)
|
else if (key == seekableKey)
|
||||||
m_seekable = !(value == QLatin1String("0"));
|
m_seekable = !(value == QLatin1String("0"));
|
||||||
else if (key == artistKey)
|
else if (key == artistKey)
|
||||||
m_artist = value;
|
m_artist = value.toString();
|
||||||
else if (key == commentKey)
|
else if (key == commentKey)
|
||||||
m_comment = value;
|
m_comment = value.toString();
|
||||||
else if (key == genreKey)
|
else if (key == genreKey)
|
||||||
m_genre = value;
|
m_genre = value.toString();
|
||||||
else if (key == yearKey)
|
else if (key == yearKey)
|
||||||
m_year = value.toInt();
|
m_year = value.toInt();
|
||||||
else if (key == bitRateKey)
|
else if (key == bitRateKey)
|
||||||
@@ -129,7 +129,7 @@ bool MmRendererMetaData::parse(const QString &contextName)
|
|||||||
else if (key == sampleKey)
|
else if (key == sampleKey)
|
||||||
m_sampleRate = value.toInt();
|
m_sampleRate = value.toInt();
|
||||||
else if (key == albumKey)
|
else if (key == albumKey)
|
||||||
m_album = value;
|
m_album = value.toString();
|
||||||
else if (key == trackKey)
|
else if (key == trackKey)
|
||||||
m_track = value.toInt();
|
m_track = value.toInt();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user