On Mon, Jan 11, 2016 at 03:04:03PM +0100, Pavel Reichl wrote:
>
>
> On 01/11/2016 02:21 PM, Jakub Hrozek wrote:
>> On Mon, Jan 11, 2016 at 02:09:48PM +0100, Sumit Bose wrote:
>>> On Mon, Jan 11, 2016 at 01:03:33PM +0100, Pavel Reichl wrote:
>>>> Hello Sumit, thanks for comments and sorry for my delayed response,
I'm addressing the issues right now, in this mail I just want quickly discuss the
concern you have about
>>>> in loop declaration.
>>>>
>>>> I generally I prefer this kind of declaration as it limits scope of
variables to minimum and thus makes it easier to read and comprehend (It makes it obvious
that variable is
>>>> used just in this single loop and it's insignificant for the rest of
the code).
>>>>
>>>> In my experience there's not a performance hit at all some even claim
that by limiting scope of variables you give hints to compiler and thus generated code is
faster.
>>>>
>>>> This topic was discussed for example here:
>>>>
>>>>
http://stackoverflow.com/questions/407255/difference-between-declaring-va...
>>>>
http://stackoverflow.com/questions/1956353/efficiency-of-c-variable-decla...
>>>>
>>>> I think that the conclusion of these threads complies with what I have
stated above. But I suppose it would be possible to find threads claiming opposite so
I'm aware it's
>>>> not definite source of truth :-)
>>>>
>>>> Anyway, If you prefer If I kept all declaration at the begging of the
function for legacy purposes or other I will do it (without any hard feelings).
>>>
>>> Thank you for the link, so it looks compilers can handle this well. I'm
>>> fine with this scheme, iirc we had this discussion for the loop index
>>> before and agreed that it makes sense to reduce the scope where possilbe
>>> to the loop. But I don't remember if there was an agreement about
>>> variabled inside the loop as well? But if we can agree on this I would
>>> like to ask you to update the paragraph in the coding style which
>>> currently reads "HIGHLY RECOMMENDED: Always declare all variables at
the
>>> top of the function, normally try to avoid declaring local variables in
>>> internal loops.".
>
> I really don't want to turn this threat into code style discussion, so I'll
do as you decide.
>
Given the current recommended coding style and the other comments in the
thread I would like to ask you to move the declaration out of the loop
to the beginning of the function.
bye,
Sumit
OK, I'll do that.
> _______________________________________________
> sssd-devel mailing list
> sssd-devel(a)lists.fedorahosted.org
>