dhaumann added a comment.

  >>> Do we dislike iterators now?
  >> 
  >> We don't, and they still make sense for when you need the `key`, but range 
for is just much nier to look at :)
  > 
  > 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.
  
  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).
  
  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.
  
  PS: Yes, it should be `const QString &dir` and `const QString &directory`, 
i.e. references and not copies.

REPOSITORY
  R297 KDED

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

To: nicolasfella, #frameworks
Cc: dhaumann, dfaure, ahmadsamir, broulik, aacid, apol, kde-frameworks-devel, 
LeGast00n, GB_2, michaelh, ngraham, bruns

Reply via email to