[Xfce4-commits] <xfwm4:master> Some small optimizations in placement code.
Nick Schermer
noreply at xfce.org
Fri Nov 30 22:56:01 CET 2012
Updating branch refs/heads/master
to e207a6bb16b5396544fa57e0b5cb5e621e8eaefb (commit)
from 515de5b8dfd1d4d2a958c38aa8460b52a6c37a47 (commit)
commit e207a6bb16b5396544fa57e0b5cb5e621e8eaefb
Author: Nick Schermer <nick at xfce.org>
Date: Fri Nov 30 22:50:59 2012 +0100
Some small optimizations in placement code.
Callgrind showed that the frameX/Y functions were called
a lot, so save the result inside the loop to do less calls.
Also inline the overlap functions, both are just simple calculations
so help the compiler a bit.
src/placement.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/placement.c b/src/placement.c
index f926de3..01f2590 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -38,9 +38,10 @@
#include "frame.h"
#include "netwm.h"
+
/* Compute rectangle overlap area */
-static unsigned long
+static inline unsigned long
segment_overlap (int x0, int x1, int tx0, int tx1)
{
if (tx0 > x0)
@@ -58,7 +59,7 @@ segment_overlap (int x0, int x1, int tx0, int tx1)
return (x1 - x0);
}
-static unsigned long
+static inline unsigned long
overlap (int x0, int y0, int x1, int y1, int tx0, int ty0, int tx1, int ty1)
{
/* Compute overlapping box */
@@ -541,6 +542,7 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
gint test_x, test_y, xmax, ymax, best_x, best_y;
gint frame_height, frame_width, frame_left, frame_top;
gboolean first;
+ gint c2_x, c2_y;
g_return_if_fail (c != NULL);
TRACE ("entering smartPlacement");
@@ -574,14 +576,17 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
&& (c->win_workspace == c2->win_workspace)
&& FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE))
{
+ c2_x = frameX (c2);
+ c2_y = frameY (c2);
+
count_overlaps += overlap (test_x - frame_left,
test_y - frame_top,
test_x - frame_left + frame_width,
test_y - frame_top + frame_height,
- frameX (c2),
- frameY (c2),
- frameX (c2) + frameWidth (c2),
- frameY (c2) + frameHeight (c2));
+ c2_x,
+ c2_y,
+ c2_x + frameWidth (c2),
+ c2_y + frameHeight (c2));
}
}
if (count_overlaps < 0.1)
More information about the Xfce4-commits
mailing list