[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-frameworks-devel
Subject: D13211: Enable comparing KFileItems by url
From: David Faure <noreply () phabricator ! kde ! org>
Date: 2018-05-30 11:59:59
Message-ID: 20180530115959.1.460B68494A141E6E () phabricator ! kde ! org
[Download RAW message or body]
dfaure requested changes to this revision.
dfaure added inline comments.
This revision now requires changes to proceed.
INLINE COMMENTS
> kfileitem.cpp:1241
> +{
> + if (!d || !other.d) {
> + return false;
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.
> kfileitem.h:493
> + */
> + bool operator<(const KFileItem &other) const;
> +
This one looks good.
> kfileitem.h:499
> + */
> + bool operator<(const QUrl &other) const;
> +
This operator seems strange to me, it's comparing a KFileItem and a QUrl, which are \
two different kinds of objects... What's the use case?
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D13211
To: jtamate, dfaure
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
[Attachment #3 (unknown)]
<table><tr><td style="">dfaure requested changes to this revision.<br />dfaure added \
inline comments.<br />This revision now requires changes to proceed. </td><a \
style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; \
color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; \
background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; \
border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D13211">View \
Revision</a></tr></table><br /><div><strong>INLINE COMMENTS</strong><div><div \
style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: \
3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; \
border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; \
background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; \
text-decoration: none;" href="https://phabricator.kde.org/D13211#inline-68629">View \
Inline</a><span style="color: #4b4d51; font-weight: \
bold;">kfileitem.cpp:1241</span></div> <div style="font: 11px/15px "Menlo", \
"Consolas", "Monaco", monospace; white-space: pre-wrap; clear: \
both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; \
background: rgba(151, 234, 151, .6);"><span class="p">{</span> </div><div \
style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span \
style="color: #aa4000">if</span> <span class="p">(</span><span style="color: \
#aa2211">!</span><span class="n">d</span> <span style="color: #aa2211">||</span> \
<span style="color: #aa2211">!</span><span class="n">other</span><span \
class="p">.</span><span class="n">d</span><span class="p">)</span> <span \
class="p">{</span> </div><div style="padding: 0 8px; margin: 0 4px; background: \
rgba(151, 234, 151, .6);"> <span style="color: #aa4000">return</span> <span \
style="color: #304a96">false</span><span class="p">;</span> </div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">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.</p>
<p style="padding: 0; margin: 8px;">If <tt style="background: #ebebeb; font-size: \
13px;">this</tt> is a valid item and <tt style="background: #ebebeb; font-size: \
13px;">other</tt> is null, then this code says that *this<other is false and \
other<*this is false.<br /> Which would let some algorithms deduce that *this == \
other, which is completely wrong.</p>
<p style="padding: 0; margin: 8px;">If we decide that a null item is inferior to \
anything else, then we need</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
"Menlo", "Consolas", "Monaco", monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">if (!d) return true; if \
(!other.d) return false;</pre></div>
<p style="padding: 0; margin: 8px;">(with newlines and braces of course).</p>
<p style="padding: 0; margin: 8px;">This also calls for a corresponding \
unittest.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: \
3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; \
border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; \
background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; \
text-decoration: none;" href="https://phabricator.kde.org/D13211#inline-68625">View \
Inline</a><span style="color: #4b4d51; font-weight: \
bold;">kfileitem.h:493</span></div> <div style="font: 11px/15px "Menlo", \
"Consolas", "Monaco", monospace; white-space: pre-wrap; clear: \
both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; \
background: rgba(151, 234, 151, .6);"><span style="color: #74777d"> */</span> \
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, \
.6);"> <span style="color: #aa4000">bool</span> <span \
class="n">operator</span><span style="color: #aa2211"><</span><span \
class="p">(</span><span style="color: #aa4000">const</span> <span \
class="n">KFileItem</span> <span style="color: #aa2211">&</span><span \
class="n">other</span><span class="p">)</span> <span style="color: \
#aa4000">const</span><span class="p">;</span> </div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This \
one looks good.</p></div></div><br /><div style="border: 1px solid #C7CCD9; \
border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: \
#e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: \
#74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: \
right; text-decoration: none;" \
href="https://phabricator.kde.org/D13211#inline-68624">View Inline</a><span \
style="color: #4b4d51; font-weight: bold;">kfileitem.h:499</span></div> <div \
style="font: 11px/15px "Menlo", "Consolas", "Monaco", \
monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div \
style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span \
style="color: #74777d"> */</span> </div><div style="padding: 0 8px; margin: 0 \
4px; background: rgba(151, 234, 151, .6);"> <span style="color: \
#aa4000">bool</span> <span class="n">operator</span><span style="color: \
#aa2211"><</span><span class="p">(</span><span style="color: #aa4000">const</span> \
<span class="n">QUrl</span> <span style="color: #aa2211">&</span><span \
class="n">other</span><span class="p">)</span> <span style="color: \
#aa4000">const</span><span class="p">;</span> </div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This \
operator seems strange to me, it's comparing a KFileItem and a QUrl, which are \
two different kinds of objects... What's the use \
case?</p></div></div></div></div></div><br \
/><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br \
/><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D13211">https://phabricator.kde.org/D13211</a></div></div><br \
/><div><strong>To: </strong>jtamate, dfaure<br /><strong>Cc: \
</strong>kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic