Ævar Arnfjörð Bjarmason <ava...@gmail.com> 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.

Reply via email to