Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Utilize ++iter rather than iter++ to improve iterator performance. #1353
@eightyeight : What makes you think the compiler won't optimize it? A lot of these corrections are a) don't rely on the compiler to optimize it for you and b) it does no harm, so may as well correct it to shut PVS Studio up.
Since the return value of the increment isn't utilized the compiler should change them to pre-increment.
Yeah, quite a few issues PVS notes are things that are probably correctly handled by the compiler, but are not explicit and therefore there is room for the compiler to handle it poorly.
Changes like this, or moving away from c-style casting tell the compiler exactly what's intended, and ensures the outcome. So it's more about consistently ensuring the desired outcome, than "the compiler never gets this right".
Even so, generally good practices to do, so hey ;)
@andr3wmac whoops, you're right, these should be optimised by the compiler as they're primitive types. Whenever I've seen a question on this subject, the advice has always been 'use pre increment anyway', which translates in my head as 'post increment will not optimise'
But yeah, I'm not disagreeing with this change.