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

Frediano Ziglio fziglio at redhat.com
Tue Nov 17 06:14:15 PST 2015


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)) {
+        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];
-- 
2.4.3



More information about the Spice-devel mailing list