<table><tr><td style="">kossebau added a comment.
</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/D25039">View Revision</a></tr></table><br /><div><div><p>As excuse for bad drive-by comment, here now hopefully making up a bit by giving some in-detail review, please see in-line comments.</p>
<p>No idea about exceptions.</p>
<p>I would the noexcept also make a different commit, for more separation of concerns. When looking at the history, such "All kind of tool-found improvements" are not nice when checking for changes which could have added regressions. IMHO.</p></div></div><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/D25039#inline-141553">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kcoredirlister.cpp:1551</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; "> <span class="n">DirItem</span> <span style="color: #aa2211">*</span><span class="n">dir</span> <span style="color: #aa2211">=</span> <span class="n">itu</span><span class="p">.</span><span class="n">value</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QUrl</span> <span style="color: #004012">oldDirUrl</span><span class="p">(</span><span class="n">itu</span><span class="p">.</span><span class="n">key</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QUrl</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">oldDirUrl</span><span class="p">(</span><span class="n">itu</span><span class="p">.</span><span class="n">key</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">qCDebug</span><span class="p">(</span><span class="n">KIO_CORE_DIRLISTER</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #766510">"itemInUse:"</span> <span style="color: #aa2211"><<</span> <span class="n">oldDirUrl</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">For consistency I would make this an assignment, IMHO also easier to read and not to be mixed up with a function call on quick sight (quick sights might be a problem of mine, but surely also others :) ):</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);">onst QUrl &oldDirUrl = itu.key();</pre></div></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/D25039#inline-141554">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kcoredirlister.cpp:1944</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; "> <span style="color: #aa4000">for</span> <span class="p">(;</span> <span class="n">itu</span> <span style="color: #aa2211">!=</span> <span class="n">ituend</span><span class="p">;</span> <span style="color: #aa2211">++</span><span class="n">itu</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="n">deletedUrl</span><span class="p">(</span><span class="n">itu</span><span class="p">.</span><span class="n">key</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">const</span> <span class="n">QUrl</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">deletedUrl</span><span class="p">(</span><span class="n">itu</span><span class="p">.</span><span class="n">key</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">dirUrl</span> <span style="color: #aa2211">==</span> <span class="n">deletedUrl</span> <span style="color: #aa2211">||</span> <span class="n">dirUrl</span><span class="p">.</span><span class="n">isParentOf</span><span class="p">(</span><span class="n">deletedUrl</span><span class="p">))</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">dito</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/D25039#inline-141558">View Inline</a><span style="color: #4b4d51; font-weight: bold;">slavebase.h:363</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; "><span style="color: #74777d"> */</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QString</span> <span style="color: #004012">configValue</span><span class="p">(</span><span class="n">QString</span> <span class="n">key</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span class="n">QString</span> <span style="color: #aa2211">&</span><span class="n">defaultValue</span><span style="color: #aa2211">=</span><span class="n">QString</span><span class="p">())</span> <span style="color: #aa4000">const</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QString</span> <span style="color: #004012">configValue</span><span class="p">(<span class="bright"></span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QString</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">key</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span class="n">QString</span> <span style="color: #aa2211">&</span><span class="n">defaultValue</span><span style="color: #aa2211">=</span><span class="n">QString</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;">while touching the line, please also add spaces around the = -> <tt style="background: #ebebeb; font-size: 13px;">defaultValue = QString())</tt></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/D25039#inline-141559">View Inline</a><span style="color: #4b4d51; font-weight: bold;">ftp.cpp:1378</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; "> <span class="n">Q_ASSERT</span><span class="p">(</span><span style="color: #aa2211">!</span><span class="n">filename</span><span class="p">.</span><span class="n">isEmpty</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QString</span> <span class="n">search</span> <span style="color: #aa2211">=</span> <span class="n">filename</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QString</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">search</span> <span style="color: #aa2211">=</span> <span class="n">filename</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This here makes the code fragile and more confusing. What is the difference between <tt style="background: #ebebeb; font-size: 13px;">filename</tt> & <tt style="background: #ebebeb; font-size: 13px;">search</tt>? Why is <tt style="background: #ebebeb; font-size: 13px;">filename</tt> not const? Can it ever change? Would that be fine for <tt style="background: #ebebeb; font-size: 13px;">search</tt> to change as well?<br />
So while seemingly a correct optimization, as <tt style="background: #ebebeb; font-size: 13px;">filename</tt> seems not passed to any method modifying it, the resulting code is very strange to a human reader, the intent behind to have <tt style="background: #ebebeb; font-size: 13px;">search</tt> being a const reference to <tt style="background: #ebebeb; font-size: 13px;">filename</tt> seems mysterious.</p>
<p style="padding: 0; margin: 8px;">Without having understood the code, I would simply also make <tt style="background: #ebebeb; font-size: 13px;">filename</tt> a const variable, and add a hint why search is a const reference only (hinting this is for optimization).<br />
Though actually <tt style="background: #ebebeb; font-size: 13px;">search</tt> could be possibly be removed and checked what the purpose of the asserts have been and merge this with the code upfront. But outside of scope here, so leaving just a TODO for the next person should be fine. One can still be the next person oneself :)</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/D25039#inline-141560">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kcookiejar.cpp:1103</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; "><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QString</span> <span class="n">domain</span><span class="p">(</span><span class="n">_domain</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QString</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">domain</span><span class="p">(</span><span class="n">_domain</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">KHttpCookieList</span> <span style="color: #aa2211">*</span><span class="n">cookieList</span> <span style="color: #aa2211">=</span> <span class="n">m_cookieDomains</span><span class="p">.</span><span class="n">value</span><span class="p">(</span><span class="n">domain</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This here seems some overleft from when the method actually needed a modfyable copy of _domain. Seems this in no longer the case.<br />
So we can just rename <tt style="background: #ebebeb; font-size: 13px;">_domain</tt> to <tt style="background: #ebebeb; font-size: 13px;">domain</tt> in the arg list instead, and be done.</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/D25039#inline-141562">View Inline</a><span style="color: #4b4d51; font-weight: bold;">script.cpp:201</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; "><span style="color: #74777d">// @returns true if @p host doesn't contains a domain part</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"><span class="n">Q_INVOKABLE</span> <span class="n">QJSValue</span> <span class="n">IsPlainHostName</span><span class="p">(</span><span class="n">QString</span> <span class="n">string</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="n">Q_INVOKABLE</span> <span class="n">QJSValue</span> <span class="n">IsPlainHostName</span><span class="p">(<span class="bright"></span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QString</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">string</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; "><span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Not an expert on Q_INVOKABLE & script access, I have seen people using non-const-ref arguments, perhaps they are needed other than with signals & slots?</p>
<p style="padding: 0; margin: 8px;">Asked the person who wrote this code in <a href="https://phabricator.kde.org/D23801#556957" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: line-through;">D23801#556957</a></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/D25039#inline-141563">View Inline</a><span style="color: #4b4d51; font-weight: bold;">sslui.cpp:87</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; "> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">KSslError</span><span style="color: #aa2211">::</span><span class="n">Error</span><span style="color: #aa2211">></span> <span class="n">errors</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="bright"></span><span class="n"><span class="bright">K</span>SslError</span> <span style="color: #aa2211">&</span><span style="color: #a0a000">error</span> <span class="p">:</span> <span class="n">qAsConst</span><span class="p">(</span><span class="n">ud</span><span style="color: #aa2211">-></span><span class="n">sslErrors</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">for</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="bright"></span><span class="n"><span class="bright">Q</span>SslError</span> <span style="color: #aa2211">&</span><span style="color: #a0a000">error</span> <span class="p">:</span> <span class="n">qAsConst</span><span class="p">(</span><span class="n">ud</span><span style="color: #aa2211">-></span><span class="n">sslErrors</span><span class="p">))</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">error</span><span class="p">.</span><span class="n">certificate</span><span class="p">()</span> <span style="color: #aa2211">==</span> <span class="n">cert</span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Seems this slipped in, being out of scope :) So please remove from patch again.</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/D25039">https://phabricator.kde.org/D25039</a></div></div><br /><div><strong>To: </strong>meven, Frameworks, dfaure<br /><strong>Cc: </strong>kossebau, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>