Menu

It might be nice to have a performance warning for Qt's foreach loop macro

2024-05-06
2024-05-22
  • Steve Albright

    Steve Albright - 2024-05-06

    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.

     
  • Daniel Marjamäki

    Thank you, I have created ticket https://trac.cppcheck.net/ticket/12755

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.