D13211: Enable comparing KFileItems by url

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


bruns added inline comments.

INLINE COMMENTS

> dfaure wrote in kfileitem.cpp:1241
> This isn't symmetric. operator< must have the property that a<b and b<a aren't both true, and that they are both false only if the items are equal.
> 
> If `this` is a valid item and `other` is null, then this code says that *this<other is false and other<*this is false.
> Which would let some algorithms deduce that *this == other, which is completely wrong.
> 
> If we decide that a null item is inferior to anything else, then we need
> 
>   if (!d) return true; if (!other.d) return false;
> 
> (with newlines and braces of course).
> 
> This also calls for a corresponding unittest.

> If we decide that a null item is inferior to anything else, then we need
>  if (!d) return true; if (!other.d) return false;

this has to be
`if (!other.d) return false; if (!d) return true;` (mind the order)

otherwise (nullptr) < (nullptr).

REPOSITORY
  R241 KIO

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

To: jtamate, dfaure
Cc: bruns, kde-frameworks-devel, michaelh, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180530/2e59d049/attachment.html>


More information about the Kde-frameworks-devel mailing list