Re: [PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

Subject: Re: [PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

Date: Fri, 30 Dec 2011 23:45:50 -0500

To: Kazuo Teramoto

Cc: notmuch@notmuchmail.org

From: Austin Clements


Shouldn't we remove the g_mime_init's from this code entirely if we're
going to do it in notmuch_database_open?

Quoth Kazuo Teramoto on Dec 30 at  7:58 pm:
> g_mime_init already check for multiple initializations.
> ---
>  lib/index.cc       |    4 ----
>  lib/message-file.c |    4 ----
>  2 files changed, 0 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index d8f8b2b..6764929 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -419,12 +419,8 @@ _notmuch_message_index_file (notmuch_message_t *message,
>      FILE *file = NULL;
>      const char *from, *subject;
>      notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
> -    static int initialized = 0;
>  
> -    if (! initialized) {
>  	g_mime_init (0);
> -	initialized = 1;
> -    }
>  
>      file = fopen (filename, "r");
>      if (! file) {
> diff --git a/lib/message-file.c b/lib/message-file.c
> index 915aba8..78c7820 100644
> --- a/lib/message-file.c
> +++ b/lib/message-file.c
> @@ -223,14 +223,10 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
>      char *header, *decoded_value, *header_sofar, *combined_header;
>      const char *s, *colon;
>      int match, newhdr, hdrsofar, is_received;
> -    static int initialized = 0;
>  
>      is_received = (strcmp(header_desired,"received") == 0);
>  
> -    if (! initialized) {
>  	g_mime_init (0);
> -	initialized = 1;
> -    }
>  
>      message->parsing_started = 1;
>  

Thread: