[vtk-developers] Coding style question: pre vs post increment operators (i++ vs ++i) (Sean McBride)

Andrew Maclean andrew.amaclean at gmail.com
Fri Jan 6 16:02:50 EST 2017

Hi Sean,

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>
> Cc:
> 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":
> <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
> --
Andrew J. P. Maclean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170107/9bc7803a/attachment.html>

More information about the vtk-developers mailing list