On Sun, Sep 2, 2012 at 4:23 PM, Pavel Sanda <sa...@lyx.org> wrote:
> Scott Kostyshak wrote:
>> (a) the style is inconsistent
>
> This is good enough reason. I did grep sources and we indeed use 
> const_iterator
> for end in most cases.
>
>> (3) I've read that compilers can apply more aggressive optimizations when 
>> more
>> of the data is const.  I'm not sure if this would apply here and even if it 
>> did
>
> That was my question because I don't think there is any difference here.
> The fact that end is not modified anywhere in the loop will be quickly
> discovered by compiler optimizations anyway.

Good point.

> It should make difference when you constify parameter of function or similar.

What about an iterator object? (that is, I'm no longer asking about
"iterator vs. const_iterator" but now "const_iterator" vs. "const
iterator const")

I was going to change "const_iterator end" to "const_iterator const
end" but it looks like the current style prefers "const_iterator end"
so I guess I should leave it:

$ git grep "const_iterator end" | wc -l
181
$ git grep "const_iterator const end" | wc -l
48
$ git grep ":iterator const end" | wc -l
14
$ git grep ":iterator end" | wc -l
69

I'm not sure what the current style says about changing "::iterator
it" to "::const_iterator it" so I will leave that as well, although I
wonder if there could be (theoretical) gains to implementing it.

Thanks Pavel,

Scott

Reply via email to