D10085: Faster drag&drop in directories with thousands of files

Mark Gaiser noreply at phabricator.kde.org
Sun Feb 4 03:26:40 GMT 2018


markg added inline comments.

INLINE COMMENTS

> draganddrophelper.cpp:36-43
> +    if (!m_cacheUrlListMatchesUrl.contains(destUrl))
> +    {
> +        m_cacheUrlListMatchesUrl.insert(destUrl,
> +            std::find_if(urls.constBegin(), urls.constEnd(), [destUrl](const QUrl& url) {
> +                return url.matches(destUrl, QUrl::StripTrailingSlash);
> +            }) != urls.constEnd() );
> +    }

You now have a double lookup in the m_cacheUrlListMatchesUrl hash. It's fast, so not that big of a deal.
But since we're in the optimizing mood here.. :)

  auto result = m_cacheUrlListMatchesUrl.find(destUrl);
  if (result != m_cacheUrlListMatchesUrl.end()) {
    return *m_cacheUrlListMatchesUrl.insert(destUrl,
      std::find_if(urls.constBegin(), urls.constEnd(), [destUrl](const QUrl& url) {
        return url.matches(destUrl, QUrl::StripTrailingSlash);
      }) != urls.constEnd() );
  } else {
    return *result;
  }

The if statement is _really_ ugly now :P
Something along those lines should work.
Note that you can directly return from the insert, it gives an iterator back and that is - if i'm right - the iterator of the just inserted data.

REPOSITORY
  R318 Dolphin

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

To: jtamate, #dolphin, elvisangelaccio, markg
Cc: markg, anthonyfieroni, michaelh, elvisangelaccio, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20180204/b21ff2ae/attachment.htm>


More information about the kfm-devel mailing list