summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-10-20 21:38:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-10-21 12:01:57 +0100
commit06d7574d7da047a6314be5af27f4ac47ccd5a350 (patch)
tree167f5bc33f9d3106e22007d8cbb9f6ed78d73422
parent1471ef82b595a207dc8873c45176ec31f277a43f (diff)
sna/damage: Stash the last freed damage for quick reallocation
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_damage.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c
index 0194f5ca..7a97c373 100644
--- a/src/sna/sna_damage.c
+++ b/src/sna/sna_damage.c
@@ -48,6 +48,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* cheapy discard no-ops.
*/
+static struct sna_damage *__freed_damage;
+
#if DEBUG_DAMAGE
#undef DBG
#define DBG(x) ErrorF x
@@ -146,7 +148,11 @@ static struct sna_damage *_sna_damage_create(void)
{
struct sna_damage *damage;
- damage = malloc(sizeof(*damage));
+ if (__freed_damage) {
+ damage = __freed_damage;
+ __freed_damage = NULL;
+ } else
+ damage = malloc(sizeof(*damage));
damage->n = 0;
damage->size = 16;
damage->elts = malloc(sizeof(*damage->elts) * damage->size);
@@ -958,7 +964,10 @@ void __sna_damage_destroy(struct sna_damage *damage)
free_list(&damage->boxes);
pixman_region_fini(&damage->region);
- free(damage);
+ if (__freed_damage == NULL)
+ __freed_damage = damage;
+ else
+ free(damage);
}
#if DEBUG_DAMAGE && TEST_DAMAGE