D16601: Replace Q_FOREACH and foreach by the range based for statement

Carl Schwan noreply at phabricator.kde.org
Thu Nov 1 21:59:43 GMT 2018


ognarb added a comment.


  In D16601#352479 <https://phabricator.kde.org/D16601#352479>, @dkurz wrote:
  
  > Replacing `Q_FOREACH` with range-based `for` actually might change performance, in case the data structure detaches. Basically, Q_FOREACH creates a const copy of the container and iterates over that, so no detaching happens.
  >
  > Since you did not use a single `qAsConst`, you might be interested in https://www.kdab.com/goodbye-q_foreach/. OTOH, not using it is sometimes correct, e.g. if you iterate over an already const container or if you are extra careful that no detaching happens in the body (which might change in the future, though).
  
  
  Interesting I will make change :D

REPOSITORY
  R76 PIM: Event Views

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

To: ognarb, #kde_pim
Cc: dkurz, kde-pim, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20181101/0f2df40b/attachment.html>


More information about the kde-pim mailing list