xf86-video-intel: src/sna/sna_trapezoids.c
Chris Wilson
ickle at kemper.freedesktop.org
Wed Feb 20 04:01:59 PST 2013
src/sna/sna_trapezoids.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 14de90b251dd8a6ff106e989580ef01cf5c2944d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Feb 20 12:00:54 2013 +0000
sna/trapezoids: Embed a few cells into the stack
Avoid an allocation in the common case where the set of trapezoids is
fairly narrow.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 4ac8b8b..d0e1bd1 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -264,6 +264,7 @@ struct cell_list {
int16_t count, size;
struct cell *cells;
+ struct cell embedded[256];
};
/* The active list contains edges in the current scan line ordered by
@@ -339,14 +340,17 @@ cell_list_init(struct cell_list *cells, int width)
cell_list_rewind(cells);
cells->count = 0;
cells->size = width+1;
- cells->cells = malloc(cells->size * sizeof(struct cell));
+ cells->cells = cells->embedded;
+ if (cells->size > ARRAY_SIZE(cells->embedded))
+ cells->cells = malloc(cells->size * sizeof(struct cell));
return cells->cells != NULL;
}
static void
cell_list_fini(struct cell_list *cells)
{
- free(cells->cells);
+ if (cells->cells != cells->embedded)
+ free(cells->cells);
}
inline static void
More information about the xorg-commit
mailing list