[Spice-devel] [PATCH] worker: simplify red_marshall_image

Pavel Grunt pgrunt at redhat.com
Wed Nov 18 00:50:26 PST 2015


Hi Frediano,

On Tue, 2015-11-17 at 14:14 +0000, Frediano Ziglio wrote:
> Remove some nested blocks using else if.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/red_worker.c | 34 +++++++++++++++-------------------
>  1 file changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 3a718fd..986908d 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -6970,27 +6970,23 @@ static void red_marshall_image(RedChannelClient *rcc,
> SpiceMarshaller *m, ImageI
>          comp_succeeded = red_jpeg_compress_image(dcc, &red_image,
>                                                   &bitmap, &comp_send_data,
>                                                   worker-
> >mem_slots.internal_groupslot_id);
> -    } else {
> -        if (quic_comp) {
> -            comp_succeeded = red_quic_compress_image(dcc, &red_image,
> &bitmap,
> -                                                     &comp_send_data,
> -                                                     worker-
> >mem_slots.internal_groupslot_id);
> -        } else {
> +    } else if (quic_comp) {
> +        comp_succeeded = red_quic_compress_image(dcc, &red_image, &bitmap,
> +                                                 &comp_send_data,
> +                                                 worker-
> >mem_slots.internal_groupslot_id);
>  #ifdef USE_LZ4
> -            if (comp_mode == SPICE_IMAGE_COMPRESSION_LZ4 &&
> -                bitmap_fmt_is_rgb(bitmap.format) &&
> -                red_channel_client_test_remote_cap(&dcc->common.base,
> -                        SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
> -                comp_succeeded = red_lz4_compress_image(dcc, &red_image,
> &bitmap,
> -                                                        &comp_send_data,
> -                                                        worker-
> >mem_slots.internal_groupslot_id);
> -            } else
> +    } else if (comp_mode == SPICE_IMAGE_COMPRESSION_LZ4 &&
> +               bitmap_fmt_is_rgb(bitmap.format) &&
> +               red_channel_client_test_remote_cap(&dcc->common.base,
> +                   SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
I would align it as the first function parameter.

Ack,
Pavel

diff --git a/server/red_worker.c b/server/red_worker.c
index 5d35d14..83d6cad 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -6930,7 +6930,7 @@ static void red_marshall_image(RedChannelClient *rcc,
SpiceMarshaller *m, ImageI
     } else if (comp_mode == SPICE_IMAGE_COMPRESSION_LZ4 &&
                bitmap_fmt_is_rgb(bitmap.format) &&
                red_channel_client_test_remote_cap(&dcc->common.base,
-                   SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
+                                                  SPICE_DISPLAY_CAP_LZ4_COMPRES
SION)) {
         comp_succeeded = red_lz4_compress_image(dcc, &red_image, &bitmap,
                                                 &comp_send_data,
                                                 worker-
>mem_slots.internal_groupslot_id);

> +        comp_succeeded = red_lz4_compress_image(dcc, &red_image, &bitmap,
> +                                                &comp_send_data,
> +                                                worker-
> >mem_slots.internal_groupslot_id);
>  #endif
> -            if (comp_mode != SPICE_IMAGE_COMPRESSION_OFF)
> -                comp_succeeded = red_lz_compress_image(dcc, &red_image,
> &bitmap,
> -                                                       &comp_send_data,
> -                                                       worker-
> >mem_slots.internal_groupslot_id);
> -        }
> +    } else if (comp_mode != SPICE_IMAGE_COMPRESSION_OFF) {
> +        comp_succeeded = red_lz_compress_image(dcc, &red_image, &bitmap,
> +                                               &comp_send_data,
> +                                               worker-
> >mem_slots.internal_groupslot_id);
>      }
>  
>      surface_lossy_region = &dcc->surface_client_lossy_region[item-
> >surface_id];


More information about the Spice-devel mailing list