[librsvg] gitlab#143 - rsvg-filter: Optimize get_/put_column



commit 6dbc5700fd8128ed167a72f955e791c2d490b06e
Author: Timm Bäder <mail baedert org>
Date:   Fri Feb 9 08:25:51 2018 -0600

    gitlab#143 - rsvg-filter: Optimize get_/put_column
    
    Use memcpy instead of a manual loop and replace the computation in every
    iteration with a simple increment.
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/143

 rsvg-filter.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index d4116e45..0a6e0f89 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -1744,15 +1744,12 @@ get_column (guchar *column_data,
             gint x)
 {
     gint y;
-    gint c;
-
+    guchar *src = src_data + (x * bpp);
     for (y = 0; y < height; y++) {
-        guchar *src = src_data + y * src_stride + x * bpp;
-
-        for (c = 0; c < bpp; c++)
-            column_data[c] = src[c];
+        memcpy (column_data, src, bpp * sizeof (guchar));
 
         column_data += bpp;
+        src += src_stride;
     }
 }
 
@@ -1760,15 +1757,12 @@ static void
 put_column (guchar *column_data, guchar *dest_data, gint dest_stride, gint bpp, gint height, gint x)
 {
     gint y;
-    gint c;
-
+    guchar *dst = dest_data + (x * bpp);
     for (y = 0; y < height; y++) {
-        guchar *dst = dest_data + y * dest_stride + x * bpp;
-
-        for (c = 0; c < bpp; c++)
-            dst[c] = column_data[c];
+        memcpy (dst, column_data, bpp * sizeof(guchar));
 
         column_data += bpp;
+        dst += dest_stride;
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]