On 01/11/2016 02:32 PM, Pavel Březina 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
>>> 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
>>> used just in this single loop and it's insignificant for the rest of the
>>> 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
>>> This topic was discussed for example here:
>>> 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
>>> 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 personally think that as soon as you start mixing variable
> declarations into code, you should maybe think about splitting the code
> into more function..
> IMO with the exception of indexes mixing code and declaration actually
> /decreases/ readability.
I must agree with Jakub on this one. Such scenario is a perfect hint that you should
decompose the code into functions. In case of get_sec_slices() it just prolongs the for
loop and makes the code harder to understand since you need to keep the scope
I think that compiler keeps scope in mind so I should make things easier.
BTW I haven't read whole Sumit's review so he might have already mentioned it but
prev seems to be pretty much useless.
Why do you think so?
I checked the code and I think it's used to link members of list...I suppose
there's better way but I can't see it right now. Do you?
> sssd-devel mailing list