summaryrefslogtreecommitdiff
path: root/src/sna/sna_accel.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-07-15 11:46:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-07-15 11:46:53 +0100
commitef6d94a8444927941db108811e1a26357dc3f18e (patch)
tree57ab986b05fb235d4e0ce867624b58f903e988d2 /src/sna/sna_accel.c
parent6601a943ff968ac39ba198351c50dc883cb4232e (diff)
sna: Simply reverse all the boxes if dx <= 0 and dy <= 0
In this fairly common case, avoid both the double pass and use a simpler algorithm as we can simply reverse the order of the boxes. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_accel.c')
-rw-r--r--src/sna/sna_accel.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index ad126150..92aca239 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3699,7 +3699,17 @@ reorder_boxes(BoxPtr box, int n, int dx, int dy)
DBG(("%s x %d dx=%d, dy=%d\n", __FUNCTION__, n, dx, dy));
- if (dy < 0) {
+ if (dy <= 0 && dx <= 0) {
+ new = malloc(sizeof(BoxRec) * n);
+ if (new == NULL)
+ return NULL;
+
+ tmp = new;
+ next = box + n;
+ do {
+ *tmp++ = *--next;
+ } while (next != box);
+ } else if (dy < 0) {
new = malloc(sizeof(BoxRec) * n);
if (new == NULL)
return NULL;
@@ -3714,16 +3724,11 @@ reorder_boxes(BoxPtr box, int n, int dx, int dy)
base = next;
}
new -= n;
- box = new;
- }
-
- if (dx < 0) {
+ } else {
new = malloc(sizeof(BoxRec) * n);
- if (!new) {
- if (dy < 0)
- free(box);
+ if (!new)
return NULL;
- }
+
base = next = box;
while (base < box + n) {
while (next < box + n && next->y1 == base->y1)
@@ -3734,10 +3739,9 @@ reorder_boxes(BoxPtr box, int n, int dx, int dy)
base = next;
}
new -= n;
- box = new;
}
- return box;
+ return new;
}
static void