From 69e233d2ba4a3e8762726aa3a168777f1df460c4 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 17 Jan 2017 14:48:08 +0300 Subject: Avoid detaching temporary objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found with clazy [detaching-temporary]: - don't call QList::first() on temporary - don't call QString::operator[]() on temporary - don't call QByteArray::data() on temporary Change-Id: I390962ef6020e4fcb0b0e447a63eed1e314d18a4 Reviewed-by: Anton Kudryavtsev Reviewed-by: Sérgio Martins --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- src/network/access/qnetworkdiskcache.cpp | 2 +- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- src/tools/uic/main.cpp | 2 +- src/widgets/widgets/qcalendarwidget.cpp | 2 +- src/widgets/widgets/qmenubar.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index b2e3df79b8..ca5af924e9 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -629,7 +629,7 @@ QString QFSFileEngine::fileName(FileName file) const bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); - return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true; + return d->fileEntry.filePath().length() ? d->fileEntry.filePath().at(0) != QLatin1Char('/') : true; } uint QFSFileEngine::ownerId(FileOwner own) const diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index ce3b773c64..d72791c1f0 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -606,7 +606,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url) QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(cleanUrl.toEncoded()); // convert sha1 to base36 form and return first 8 bytes for use as string - QByteArray id = QByteArray::number(*(qlonglong*)hash.result().data(), 36).left(8); + const QByteArray id = QByteArray::number(*(qlonglong*)hash.result().constData(), 36).left(8); // generates /<8-char filname.d> uint code = (uint)id.at(id.length()-1) % 16; QString pathFragment = QString::number(code, 16) + QLatin1Char('/') diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 70c4aa563c..6561e95a0d 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1398,7 +1398,7 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS sendReply(connection, message, QVariant::fromValue( QDBusVariant(QVariant::fromValue(QSpiObjectReference(connection, QDBusObjectPath(path)))))); } else if (function == QLatin1String("GetChildAtIndex")) { - int index = message.arguments().first().toInt(); + const int index = message.arguments().at(0).toInt(); if (index < 0) { sendReply(connection, message, QVariant::fromValue( QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL)))); diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index e2399cd1fd..fca604690e 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -115,7 +115,7 @@ int runUic(int argc, char *argv[]) QString inputFile; if (!parser.positionalArguments().isEmpty()) - inputFile = parser.positionalArguments().first(); + inputFile = parser.positionalArguments().at(0); else // reading from stdin driver.option().headerProtection = false; diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index b0ded70c4a..da4850a816 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -765,7 +765,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) if (m_widget) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent* ke = (QKeyEvent*)e; - if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) { + if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { applyDate(); emit editingFinished(); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index ce43740524..cec5d512fd 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1119,7 +1119,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) int clashCount = 0; QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; { - QChar c = e->text()[0].toUpper(); + const QChar c = e->text().at(0).toUpper(); for(int i = 0; i < d->actions.size(); ++i) { if (d->actionRects.at(i).isNull()) continue; -- cgit v1.2.3