D24262: Modernize code: use range-based loops & algorithms in more places

David Faure noreply at phabricator.kde.org
Sun Sep 29 22:44:19 BST 2019


dfaure requested changes to this revision.
dfaure added a comment.
This revision now requires changes to proceed.


  Please make the loop variable const-ref whenever possible.

INLINE COMMENTS

> browseropenorsavequestion.cpp:270
>                  QObject::connect(menu, &QMenu::triggered, d, &BrowserOpenOrSaveQuestionPrivate::slotAppSelected);
> -                for (KService::List::const_iterator it = apps.begin(); it != apps.end(); ++it) {
> -                    QAction *act = createAppAction(*it, d);
> +                for (auto& app : apps) {
> +                    QAction *act = createAppAction(app, d);

Why not *const* auto &app?

> plugin.cpp:138
>  {
> -    QList<PluginInfo>::ConstIterator pIt = pluginInfos.begin();
> -    QList<PluginInfo>::ConstIterator pEnd = pluginInfos.end();
> -    for (; pIt != pEnd; ++pIt) {
> -        QString library = (*pIt).m_document.documentElement().attribute(QStringLiteral("library"));
> +    for (auto& pluginInfo : pluginInfos) {
> +        const QString library = pluginInfo.m_document.documentElement().attribute(QStringLiteral("library"));

const auto &

(space before '&', btw, not after)

> plugin.cpp:214
>      const QList<PluginInfo> plugins = pluginInfos(componentName);
> -    QList<PluginInfo>::ConstIterator pIt = plugins.begin();
> -    const QList<PluginInfo>::ConstIterator pEnd = plugins.end();
> -    for (; pIt != pEnd; ++pIt) {
> -        QDomElement docElem = (*pIt).m_document.documentElement();
> +    for (auto& pluginInfo : plugins) {
> +        QDomElement docElem = pluginInfo.m_document.documentElement();

const...

> scriptableextension.cpp:260
>      qargs.reserve(a.size());
> -    for (int i = 0; i < a.size(); ++i) {
> +    for (auto& arg : a) {
>          bool ok;

const

REPOSITORY
  R306 KParts

REVISION DETAIL
  https://phabricator.kde.org/D24262

To: kossebau, dfaure
Cc: ahmadsamir, dhaumann, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190929/ff9a8164/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list