D19897: [kservice ] Make it compile without foreach

David Faure noreply at phabricator.kde.org
Wed Mar 20 08:43:29 GMT 2019


dfaure accepted this revision.
dfaure added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> vfolder_menu.cpp:125
>  {
> -    foreach (const KService::Ptr &p, items1) {
> +    const QHash<QString, KService::Ptr> tmpItems1 = items1;
> +    for (const KService::Ptr &p : tmpItems1) {

This makes me realize that this code was indeed detaching a copy of items1.
Good catch.
But better code would use a java-style iterator and call remove(), to avoid the copy and the extra lookup at remove time.

This can be a separate commit, this port is correct.

REPOSITORY
  R309 KService

BRANCH
  compile_without_foreach (branched from master)

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

To: mlaurent, dfaure
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190320/19a9e412/attachment.html>


More information about the Kde-frameworks-devel mailing list