[Xfce4-commits] <xfwm4:xfce-4.10> Small optimization in shadow loop.

Nick Schermer noreply at xfce.org
Sun May 5 18:00:04 CEST 2013


Updating branch refs/heads/xfce-4.10
         to 406ef4963d89aba8abadb79dae3f32a5b2addd9e (commit)
       from 84d9d0b9b846bc98e6ebea543fd8ebb2f67a38a1 (commit)

commit 406ef4963d89aba8abadb79dae3f32a5b2addd9e
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Dec 1 14:00:02 2012 +0100

    Small optimization in shadow loop.
    
    Do some caclulations outside the loop or store them,
    callgrind showed this loop was called _a lot_ and spend
    most of the time in this part of the code.
    
    (cherry picked from commit d4f2512d3826f745593a015a1699f9d867c030b8)

 src/compositor.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index c0ce4ea..428989c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -421,6 +421,8 @@ make_shadow (ScreenInfo *screen_info, gdouble opacity, gint width, gint height)
     gint x, y;
     gint x_diff;
     gint opacity_int;
+    gint x_swidth;
+    gint y_swidth;
 
     g_return_val_if_fail (screen_info != NULL, NULL);
     TRACE ("entering make_shadow");
@@ -537,10 +539,12 @@ make_shadow (ScreenInfo *screen_info, gdouble opacity, gint width, gint height)
         {
             d = sum_gaussian (screen_info->gaussianMap, opacity, x - center, center, width, height);
         }
+        x_swidth = swidth - x - 1;
         for (y = gaussianSize; y < sheight - gaussianSize; y++)
         {
-            data[y * swidth + x] = d;
-            data[y * swidth + (swidth - x - 1)] = d;
+            y_swidth = y * swidth;
+            data[y_swidth + x] = d;
+            data[y_swidth + x_swidth] = d;
         }
     }
 


More information about the Xfce4-commits mailing list