Jani Nikula <j...@nikula.org> writes:

> On Thu, 24 Sep 2015, David Bremner <da...@tethera.net> wrote:
>> Jani Nikula <j...@nikula.org> writes:
>>
>>
>>> +    else
>>> +   v = !!m1->name - !!m2->name;
>>
>> Is this really idiomatic? It seems a little difficult to follow to me.
>
> Probably depends on whether you're accustomed to using !! for
> "normalizing" zero and non-zero to 0 and 1, respectively.
>
> The alternative seemed a bit too verbose for my liking:
>
>     if (m1->name && m2->name)
>         v = strcmp (m1->name, m2->name);
>     else if (!m1->name && !m2->name)
>         v = 0;
>     else if (m1->name)
>         v = 1;
>     else
>         v = -1;
>

What about adding the verbose version to string-util.c as
e.g. strcmp_null. Theres apparently similar functions in the linux
kernel, gnome-vfs, subversion...

https://codesearch.debian.net/results/strcmp_null/page_0



_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to