With more modern C++ the range based for is better and when you use it Clazy wakes up and decides if you need to do reserves on containers too. The Qt version always does a copy of the container you are looping on.
Unfortunately, if you aren't using Clazy, you don't know if the container you are looping on also needs qAsConst (or other const reference changes).
I've manually fixed this in many repos but would likely get less pushback if it were a cppcheck warning and new usages wouldn't sneak in.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
With more modern C++ the range based for is better and when you use it Clazy wakes up and decides if you need to do reserves on containers too. The Qt version always does a copy of the container you are looping on.
Unfortunately, if you aren't using Clazy, you don't know if the container you are looping on also needs qAsConst (or other const reference changes).
I've manually fixed this in many repos but would likely get less pushback if it were a cppcheck warning and new usages wouldn't sneak in.
Thank you, I have created ticket https://trac.cppcheck.net/ticket/12755