D7110: Reduce heap allocs by using QVector instead of QList

Daniel Vrátil noreply at phabricator.kde.org
Fri Aug 4 11:55:09 BST 2017


dvratil added a comment.


  Technically, since the list here is only created so that it can be effectively iterated over, you could just do
  
    const auto myActions = { .....  };
  
  The deduced type will be `std::initializer_list<T>`, which is just a light wrapper for an array which can be iterated over in range-based loops. This is probably even more light-weight and faster than using `QVector`.
  
  Also for `QList<T>` where `sizeof(T) <= sizeof(void*)`, QList uses an optimization and stores the values directly in the contigous pointer array, thus behaving the same way as QVector more or less.

REPOSITORY
  R206 KMail

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

To: dkurz, #kde_pim_kmail
Cc: dvratil, mlaurent, #kde_pim, dvasin, winterz, vkrause, knauss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20170804/5e63b438/attachment.html>


More information about the kde-pim mailing list