D10742: get rid of the raw KFileItem pointers in KCoreDirListerCache

Stefan BrĂ¼ns noreply at phabricator.kde.org
Wed May 23 14:30:31 UTC 2018


bruns added inline comments.

INLINE COMMENTS

> kcoredirlister_p.h:302
> +    // Remove the item from the sorted list (from the wrong place) and insert it in the right place.
> +    void reinsert(KFileItem &item, const QUrl &oldUrl)
> +    {

This can be better implemented with std::move and std::move_backward from <algorithm>
http://www.cplusplus.com/reference/algorithm/move/

1. calculate start and end iterators from the old and new URL
2. move old item to tmp
3.

  if (old_it < new_it) {
     std::move(old_it + 1, new_it, old_it); // move downwards
  } else {
     std::move_backward(new_it , old_it - 1, old_it);
  }
  *new_it = tmp;

> kfileitem.cpp:180
> +    // The hash of the url for faster std::lower_bound
> +    uint m_hash;
>  };

You can probably leave this out if you use the following for ordering:

  bool operator< (const KFileItem& other) {
    if m_url.size() != other.m_url.size() {
      return m_url.size() < other.m_url.size()
    }
    return m_url < other.m_url;
  }

You don't need lexicographical sorting, but just a total ordering for the lookup.

REPOSITORY
  R241 KIO

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

To: jtamate, #frameworks, dfaure
Cc: bruns, kde-frameworks-devel, mwolff, markg, michaelh, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180523/eb989725/attachment.html>


More information about the Kde-frameworks-devel mailing list