[vtk-developers] Coding style question: pre vs post increment operators (i++ vs ++i)
Sean McBride
sean at rogue-research.com
Thu Jan 5 12:24:00 EST 2017
Hi all,
cppcheck has a warning where it suggests "performance: Prefer prefix ++/-- operators for non-primitive types":
<https://open.cdash.org/viewBuildError.php?type=1&buildid=4710441>
The LLVM coding standards, for example, have a similar policy (and explanation):
<http://llvm.org/docs/CodingStandards.html#prefer-preincrement>
cppcheck gives bazillions of such warnings in VTK and I originally suppressed them all. More recently, I now suppress only some folders, leaving the warning enabled for those folders where there are no warnings currently. This has the effect therefore of such warnings now popping up for new code or changes to previously warning-free code (as seen on the dashboard now).
What do we want to do? Start preferring preincrement (for non-primitive types!) in new code? or I suppress the warning entirely?
(When we start allowing C++11 using range-based for will eliminate many such increments, but leaving that aside...)
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng sean at rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
More information about the vtk-developers
mailing list