[Spice-devel] [PATCH] simplify #ifdef code

Jonathon Jongsma jjongsma at redhat.com
Tue May 17 19:35:06 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>


On Fri, 2016-05-13 at 13:17 +0100, Frediano Ziglio wrote:
> Reduce conditional code
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  common/lz_compress_tmpl.c | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)
> 
> Better to see this patch without space changes (and the
> looking result).
> 
> diff --git a/common/lz_compress_tmpl.c b/common/lz_compress_tmpl.c
> index 0305278..1bb5c75 100644
> --- a/common/lz_compress_tmpl.c
> +++ b/common/lz_compress_tmpl.c
> @@ -403,27 +403,23 @@ match:        // RLE or dictionary (both are encoded by
> distance from ref (-1) a
>  
>          /* update the hash at match boundary */
>  #if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32)
> -        if (ip > anchor) {
> +        if (ip > anchor)
>  #endif
> -        HASH_FUNC(hval, ip);
> -        encoder->htab[hval].ref = (uint8_t *)ip;
> +        {
> +            HASH_FUNC(hval, ip);
> +            encoder->htab[hval].ref = (uint8_t *)ip;
> +            encoder->htab[hval].image_seg = seg;
> +        }
>          ip++;
> -        encoder->htab[hval].image_seg = seg;
> -#if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32)
> -    } else {ip++;
> -    }
> -#endif
>  #if defined(LZ_RGB24) || defined(LZ_RGB32)
> -        if (ip > anchor) {
> +        if (ip > anchor)
>  #endif
> -        HASH_FUNC(hval, ip);
> -        encoder->htab[hval].ref = (uint8_t *)ip;
> +        {
> +            HASH_FUNC(hval, ip);
> +            encoder->htab[hval].ref = (uint8_t *)ip;
> +            encoder->htab[hval].image_seg = seg;
> +        }
>          ip++;
> -        encoder->htab[hval].image_seg = seg;
> -#if defined(LZ_RGB24) || defined(LZ_RGB32)
> -    } else {ip++;
> -    }
> -#endif
>          /* assuming literal copy */
>          encode_copy_count(encoder, MAX_COPY - 1);
>          continue;


More information about the Spice-devel mailing list