[Spice-devel] [PATCH spice-common 3/5] lz: Avoid temporary variable

Frediano Ziglio fziglio at redhat.com
Wed Jan 17 15:55:18 UTC 2018


Use a break to exit the loop instead of using a variable.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 common/lz_decompress_tmpl.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 04a5121..0189f86 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -222,9 +222,8 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
     OUT_PIXEL    *op = out_buf;
     OUT_PIXEL    *op_limit = out_buf + size;
     uint32_t ctrl = decode(encoder);
-    int loop = TRUE;
 
-    do {
+    for (;;) {
         const OUT_PIXEL *ref = op;
         uint32_t len = ctrl >> 5;
         uint32_t ofs = (ctrl & 31) << 8; // 5 MSb of distance
@@ -312,12 +311,11 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
             }
         }
 
-        if (LZ_EXPECT_CONDITIONAL(op < op_limit)) {
-            ctrl = decode(encoder);
-        } else {
-            loop = FALSE;
+        if (LZ_UNEXPECT_CONDITIONAL(op >= op_limit)) {
+            break;
         }
-    } while (LZ_EXPECT_CONDITIONAL(loop));
+        ctrl = decode(encoder);
+    }
 
     return (op - out_buf);
 }
-- 
2.14.3



More information about the Spice-devel mailing list