[vtk-developers] Coding style question: pre vs post increment operators (i++ vs ++i) (Sean McBride)
andrew.amaclean at gmail.com
Fri Jan 6 16:02:50 EST 2017
In my opinion leave it in, we should start preferring preincrement, so
don't suppress the warning..
The reasons are:
1) It alerts coders to performance issues.
2) VTK is huge and anything that improves the code base is a good thing as
it makes future maintenance easier.
3) Warnings like this alert users to possible future issues.
Where I have edited code, I have corrected issues like this.
As an aside I also can't wait for range-based for loops and auto to be used
in VTK! Roll on C++11.
BTW Your coding standards link makes really interesting reading.
On Sat, Jan 7, 2017 at 4:00 AM, <vtk-developers-request at vtk.org> wrote:
> Send vtk-developers mailing list submissions to
> ---------- Forwarded message ----------
> From: Sean McBride <sean at rogue-research.com>
> To: <vtk-developers at vtk.org>
> Date: Thu, 5 Jan 2017 12:24:00 -0500
> Subject: [vtk-developers] Coding style question: pre vs post increment
> operators (i++ vs ++i)
> Hi all,
> cppcheck has a warning where it suggests "performance: Prefer prefix ++/--
> operators for non-primitive types":
> The LLVM coding standards, for example, have a similar policy (and
> 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...)
> Sean McBride, B. Eng sean at rogue-research.com
> Rogue Research www.rogue-research.com
> Mac Software Developer Montréal, Québec, Canada
Andrew J. P. Maclean
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtk-developers