Re: [PATCH 16/16] add: avoid yoda conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 31, 2013 at 2:31 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:

> I agree that there is no justification to write "if 0 == something",
> when "if something == 0" suffices.  The latter reads better and that
> is why the phrase "yoda condition" was invented.
>
> But the situation is different when both sides are not constants,
> and especially when "<" and "<=" are involved..

To me revs.nr is virtually a constant, I'm comparing i to revs.nr, not
the other way around.

I believe I explained this already, but here it goes again:

if (1.60 < john.size)

This makes no sense, "if 1.69 is smaller than john"?

The situation doesn't change when you use a variable:

if (size_limit < john.size)

Translates to "if size limit is smaller than john", and still makes no sense.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]