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

Dominik Haumann noreply at phabricator.kde.org
Sat Sep 28 07:19:39 BST 2019


dhaumann added inline comments.

INLINE COMMENTS

> plugin.cpp:196
>  
> -    QObjectList::ConstIterator it = plugins.begin();
> -    for (; it != plugins.end(); ++it) {
> -        Plugin *plugin = qobject_cast<Plugin *>(*it);
> -        if (plugin && plugin->d->m_library == library) {
> -            return true;
> -        }
> -    }
> -    return false;
> +    return std::any_of(plugins.begin(), plugins.end(), [library](QObject* p) {
> +        Plugin *plugin = qobject_cast<Plugin *>(p);

cbegin() + cend()
Catch library by reference? [& library]

> statusbarextension.cpp:139
>      if (d->m_activated) {
> -        QList<StatusBarItem>::iterator it = d->m_statusBarItems.begin();
> -        for (; it != d->m_statusBarItems.end(); ++it) {
> -            (*it).ensureItemShown(sb);
> +        for (auto& item : d->m_statusBarItems) {
> +            item.ensureItemShown(sb);

qAsConst?

> statusbarextension.cpp:143
>      } else {
> -        QList<StatusBarItem>::iterator it = d->m_statusBarItems.begin();
> -        for (; it != d->m_statusBarItems.end(); ++it) {
> -            (*it).ensureItemHidden(sb);
> +        for (auto& item : d->m_statusBarItems) {
> +            item.ensureItemHidden(sb);

Same here?

REPOSITORY
  R306 KParts

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

To: kossebau, dfaure
Cc: 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/20190928/165b4428/attachment.html>


More information about the Kde-frameworks-devel mailing list