[Spice-devel] [PATCH] glz: simplification of PIXEL_DIST calls

Frediano Ziglio fziglio at redhat.com
Tue May 17 10:06:24 UTC 2016


Make macro have same prototype even if we need an extra argument.
This avoids having different calls for LZ_PLT.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/glz-encode.tmpl.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/server/glz-encode.tmpl.c b/server/glz-encode.tmpl.c
index 46dd1d4..8fc551d 100644
--- a/server/glz-encode.tmpl.c
+++ b/server/glz-encode.tmpl.c
@@ -131,7 +131,7 @@
 #ifndef LZ_PLT
 #define PIXEL_ID(pix_ptr, seg_ptr) \
     ((pix_ptr) - ((PIXEL *)(seg_ptr)->lines) + (seg_ptr)->pixels_so_far)
-#define PIXEL_DIST(src_pix_ptr, src_seg_ptr, ref_pix_ptr, ref_seg_ptr) \
+#define PIXEL_DIST(src_pix_ptr, src_seg_ptr, ref_pix_ptr, ref_seg_ptr, pix_per_byte) \
     (PIXEL_ID(src_pix_ptr,src_seg_ptr) - PIXEL_ID(ref_pix_ptr, ref_seg_ptr))
 #else
 #define PIXEL_ID(pix_ptr, seg_ptr, pix_per_byte) \
@@ -202,25 +202,12 @@ static inline size_t FNAME(do_match)(SharedDictionary *dict,
     *o_image_dist = ip_seg->image->id - ref_seg->image->id;
 
     if (!(*o_image_dist)) { // the ref is inside the same image - encode distance
-#ifndef LZ_PLT
-        *o_pix_distance = PIXEL_DIST(ip, ip_seg, ref, ref_seg);
-#else
-        // in bytes
         *o_pix_distance = PIXEL_DIST(ip, ip_seg, ref, ref_seg, pix_per_byte);
-#endif
     } else { // the ref is at different image - encode offset from the image start
-#ifndef LZ_PLT
-        *o_pix_distance = PIXEL_DIST(ref, ref_seg,
-                                     (PIXEL *)(dict->window.segs[ref_seg->image->first_seg].lines),
-                                     &dict->window.segs[ref_seg->image->first_seg]
-                                     );
-#else
-        // in bytes
         *o_pix_distance = PIXEL_DIST(ref, ref_seg,
                                      (PIXEL *)(dict->window.segs[ref_seg->image->first_seg].lines),
                                      &dict->window.segs[ref_seg->image->first_seg],
                                      pix_per_byte);
-#endif
     }
 
     if ((*o_pix_distance == 0) || (*o_pix_distance >= MAX_PIXEL_LONG_DISTANCE) ||
-- 
2.7.4



More information about the Spice-devel mailing list