Re: [patch] change increment/decrement operators from postfix to prefix

From: Kinkie <gkinkie_at_gmail.com>
Date: Mon, 2 Jul 2012 14:03:21 +0200

On Mon, Jul 2, 2012 at 1:26 PM, Amos Jeffries <squid3_at_treenet.co.nz> wrote:
> On 2/07/2012 10:08 p.m., Kinkie wrote:
>>
>> Hi all,
>> this patch (for trunk) is a first chunk of a janitorial task
>> changing all operator++ and operator-- from postfix to prefix form
>> where it doesn't impact the code flow. There are other cases where a
>> more in-depth refactoring may improve readability, but I'll save them
>> for more focused activities.
>> I'd like to be authorized to commit directly to trunk for this (and
>> subsequent) chunks.
>>
>> Thoughts?
>
>
> Any profiling done to show the benefits?
>
> I'm finding a LOT of mixed results from many people on which of pre/post
> increment is actually faster.
> The rule of thumb was created decades ago when compiler auto-optimization
> was young.
>
> ++1 from me. IMO this can go on trunk anytime.
>
> Cleanup re-naming of symbols is where we need to be careful. Because I can
> get a little mixed up when porting followup pathes to an older branch.

I started after some literature checking, it seems that:
- it is probably now not really useful anymore for builtin types
- it is probably still useful for everything else, including iterators
- changing can help spot readability problems.

I confirm the scope. The patch includes one exception, and that is
when a static variable was used in place of a bool, and postincrement
was used for initialize_once pattern. I've changed that to a proper
bool.

Ok, I'll commit and also commit subsequent chunks, trying to keep the
commits to manageable sizes.

Thanks,

-- 
    /kinkie
Received on Mon Jul 02 2012 - 12:03:27 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 02 2012 - 12:00:05 MDT