From: Junio C Hamano Date: Tue, 19 Mar 2019 04:08:50 GMT Subject: Re: [PATCH 2/3] midx: verify: group objects by packfile to speed up object verification Message-ID: In-Reply-To: <87lg1bet9d.fsf@evledraar.gmail.com> Ævar Arnfjörð Bjarmason writes: >>>> + if (a->pack_int_id < b->pack_int_id) >>>> + return -1; >>>> + if (a->pack_int_id > b->pack_int_id) >>>> + return 1; >>>> + >>>> + return 0; >>>> +} >>> ... >>> succinct subtraction idiom of e.g. (in this case): >>> >>> return b->pack_int_id - a->pack_int_id; >> ... >> On 43+M objects, your version is a hair faster, so I might >> as well take it instead. > > Cool! Yup, following a well-known short idiom lets readers' eyes coast over without forcing them to make sure the two if statements have comparison going in the right direction and return the constant with the right sign, etc. Even if the idiomatic version weren't faster, it is worth using it. Thanks.