D22087: Build without foreach
Aleix Pol Gonzalez
noreply at phabricator.kde.org
Sat Jul 27 23:59:31 BST 2019
apol added a comment.
+1 overall
INLINE COMMENTS
> powermanagementengine.cpp:442
> uint unnamedBatteries = 0;
> - foreach (QString source, m_batterySources) {
> + for (QString source : qAsConst(m_batterySources)) {
> DataContainer *batteryDataContainer = containerForSource(source);
const &
> shareengine.cpp:54
> QMultiMap<int, KService::Ptr> sortedServices;
> - foreach (KService::Ptr service, services) {
> + for (KService::Ptr service : services) {
> sortedServices.insert(service->property(QStringLiteral("X-KDE-Priority")).toInt(), service);
const &
> dbusmenushortcut_p.cpp:60
> + const QStringList tokens = string.split(QStringLiteral(", "));
> + for (QString token : tokens) {
> // Hack: Qt::CTRL | Qt::Key_Plus is turned into the string "Ctrl++",
const &, also this should possibly be transformed into a splitRef.
> dbusmenushortcut_p.cpp:75
> QStringList tmp;
> - Q_FOREACH(const QStringList& keyTokens_, *this) {
> + for (const QStringList& keyTokens_: qAsConst(*this)) {
> QStringList keyTokens = keyTokens_;
this is already const, no?
weirdest foreach in KDE xD 🏅
> bookmarksrunner.cpp:86
> + const QList<BookmarkMatch> matches = m_browser->match(term, allBookmarks);
> + for (BookmarkMatch match : matches) {
> if(!context.isValid())
const &?
> chrome.cpp:54
> + const auto profiles = findProfile->find();
> + for (Profile profile : profiles) {
> m_profileBookmarks << new ProfileBookmarks(profile);
const&?
> firefox.cpp:102
> + const QList<QVariantMap> results = m_fetchsqlite->query(query, QMap<QString, QVariant>());
> QMultiMap<QString, QString> uniqueResults;
> + for (QVariantMap result : results) {
const &
> screenpool.cpp:174
> //m_connectorForId is the only map, so the ids are sorted
> - foreach (int existingId, m_connectorForId.keys()) {
> + const auto keys = m_connectorForId.keys();
> + for (int existingId : keys) {
Iterating through keys isn't very optimal, I'd use iterators here.
REPOSITORY
R120 Plasma Workspace
REVISION DETAIL
https://phabricator.kde.org/D22087
To: nicolasfella, #plasma
Cc: apol, plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20190727/194aedb0/attachment-0001.html>
More information about the Plasma-devel
mailing list