[Patch 1/2] separate handling when addresses == NULL

Austin Clements amdragon at MIT.EDU
Fri Dec 9 07:57:21 PST 2011


Quoth Tomi Ollila on Dec 09 at  3:52 pm:
> When addresses is NULL, (future) addresses object cleanup is not needed.
> ---
>  notmuch-show.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 603992a..c27ef6a 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -239,7 +239,11 @@ _extract_email_address (const void *ctx, const char *from)
>      addresses = internet_address_list_parse_string (from);
>  
>      /* Bail if there is no address here. */
> -    if (addresses == NULL || internet_address_list_length (addresses) < 1)
> +    if (addresses == NULL)
> +	return email;
> +
> +    /* Bail if there is no address here. */
> +    if (internet_address_list_length (addresses) < 1)
>  	goto DONE;

Personally, I would much prefer to see the code as it was---with the
sometimes unnecessary goto DONE---and an if (addresses) around the
later cleanup that the second patch adds.  It's more maintainable in
case someone ever adds more code earlier in this function and this
microoptimization isn't buying you anything.

>  
>      /* Otherwise, just use the first address. */


More information about the notmuch mailing list