On 11/10/13 05:08, slavomir vlcek wrote:
> From: slavomir vlcek <[email protected]>
> Date: Thu, 10 Oct 2013 17:25:22 +0200
> Subject: [PATCH] libalpm: move function pointer condition
> 
> Function pointer gets uselessly compared for NULL in
> every iteration. Move the condition to do it just once.
> 
> Signed-off-by: slavomir vlcek <[email protected]>

Ack.  Looks good.

Allan

> ---
> 
> Hi,
> sending small performance patch.
> Haven't actually tried to compile it with this patch.
> So i hope there will be no syntax error.
> Thanks.
> 
>  lib/libalpm/alpm_list.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
> index 59f99f9..a3c73aa 100644
> --- a/lib/libalpm/alpm_list.c
> +++ b/lib/libalpm/alpm_list.c
> @@ -70,11 +70,13 @@ void SYMEXPORT alpm_list_free_inner(alpm_list_t *list, 
> alpm_list_fn_free fn)
>  {
>       alpm_list_t *it = list;
>  
> -     while(it) {
> -             if(fn && it->data) {
> -                     fn(it->data);
> +     if(fn) {
> +             while(it) {
> +                     if(it->data) {
> +                             fn(it->data);
> +                     }
> +                     it = it->next;
>               }
> -             it = it->next;
>       }
>  }
>  
> 


Reply via email to