1
From e207a6bb16b5396544fa57e0b5cb5e621e8eaefb Mon Sep 17 00:00:00 2001
2
From: Nick Schermer <nick@xfce.org>
3
Date: Fri, 30 Nov 2012 22:50:59 +0100
4
Subject: [PATCH] Some small optimizations in placement code.
6
Callgrind showed that the frameX/Y functions were called
7
a lot, so save the result inside the loop to do less calls.
9
Also inline the overlap functions, both are just simple calculations
10
so help the compiler a bit.
12
src/placement.c | 17 +++++++++++------
13
1 file changed, 11 insertions(+), 6 deletions(-)
15
diff --git a/src/placement.c b/src/placement.c
16
index f926de3..01f2590 100644
24
/* Compute rectangle overlap area */
27
+static inline unsigned long
28
segment_overlap (int x0, int x1, int tx0, int tx1)
31
@@ -58,7 +59,7 @@ segment_overlap (int x0, int x1, int tx0, int tx1)
36
+static inline unsigned long
37
overlap (int x0, int y0, int x1, int y1, int tx0, int ty0, int tx1, int ty1)
39
/* Compute overlapping box */
40
@@ -541,6 +542,7 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
41
gint test_x, test_y, xmax, ymax, best_x, best_y;
42
gint frame_height, frame_width, frame_left, frame_top;
46
g_return_if_fail (c != NULL);
47
TRACE ("entering smartPlacement");
48
@@ -574,14 +576,17 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
49
&& (c->win_workspace == c2->win_workspace)
50
&& FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE))
55
count_overlaps += overlap (test_x - frame_left,
57
test_x - frame_left + frame_width,
58
test_y - frame_top + frame_height,
61
- frameX (c2) + frameWidth (c2),
62
- frameY (c2) + frameHeight (c2));
65
+ c2_x + frameWidth (c2),
66
+ c2_y + frameHeight (c2));
69
if (count_overlaps < 0.1)