Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH 06/17: compctl: Remove pointless check
On Tue, Jan 6, 2015 at 10:43 AM, Kamil Dudka <kdudka@xxxxxxxxxx> wrote:
> On Monday 05 January 2015 23:53:02 Bart Schaefer wrote:
>> On Jan 6, 6:25am, Mikael Magnusson wrote:
>> } Subject: PATCH 06/17: compctl: Remove pointless check
>> }
>> } cc has already been derefed a bunch of times leading up to here. Found
>> } by Coverity (Issue 1255841).
>> } - if (cc && cc->xor) {
>> } + if (cc->xor) {
>>
>> I'm curious, why bother to "fix" this (and a couple of similar others in
>> later patches in this series)? It's not *wrong*, and the change is not
>> a significant optimization.
>
> True, modern compilers would optimize out such checks anyway in some cases.
> Nevertheless, I believe that putting it explicit makes the code easier to
> understand for a human reader.
If you look at the bigger context, it's something like
if (cc->foo) {
...
}
if (cc->bar) {
...
}
if (cc->baz) {
...
}
repeated maybe 17 times, and then suddenly
if (cc && cc->xor) {
...
}
and it sort of makes you wonder if something suddenly could have
changed cc, but indeed there is not.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author