<table><tr><td style="">dhaumann 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/D25755">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Do we dislike iterators now?</p></blockquote>
<p>We don't, and they still make sense for when you need the <tt style="background: #ebebeb; font-size: 13px;">key</tt>, but range for is just much nier to look at :)</p></blockquote>
<p>I'm fine with that statement. But are we going to be reviewing changing all the KDE code from iterators to range for? Feels like an overkill to me.</p></blockquote>
<p>It's much more than just the fact "it's nicer to look at". It' i) more compact, but more importantly, it's ii) simpler to reason about. When having iterator-based loops you cannot immediately say "we iterate over all items". It could be that the iterator is not increased, or it is increased in the body scope multiple times. Contrary, with range-based for loops you know what you *always* iterate over all items (except if there is a shortcut break/return statement).</p>
<p>The only nitpick is: In the Qt world this is sometimes tricky when using range-based for loops over non-const Qt containers, which leads to a detach. So review is typically necessary.</p>
<p>PS: Yes, it should be <tt style="background: #ebebeb; font-size: 13px;">const QString &dir</tt> and <tt style="background: #ebebeb; font-size: 13px;">const QString &directory</tt>, i.e. references and not copies.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R297 KDED</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25755">https://phabricator.kde.org/D25755</a></div></div><br /><div><strong>To: </strong>nicolasfella, Frameworks<br /><strong>Cc: </strong>dhaumann, dfaure, ahmadsamir, broulik, aacid, apol, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>