summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-04-25 17:36:47 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-04-25 17:36:47 +0100
commit694b76d2a5e96a33090b7cdc0be50f213008ecaa (patch)
tree2e59c12f28f20697a5deeeb73b12f9bc9a498048
parentaefa675dbbd1ce0296c9322e02e238d1cc181f01 (diff)
Cache the last Allocator lookup.
-rw-r--r--src/allocators.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/allocators.c b/src/allocators.c
index 28cec49..23be621 100644
--- a/src/allocators.c
+++ b/src/allocators.c
@@ -112,6 +112,7 @@ static void
allocators_set_blocks (Allocators *self, Block *blocks)
{
Block *b, **block_mem;
+ Allocator *lastA = NULL;
AllocatorsStore *store;
struct _sum_allocator *sum, *sums;
gulong pagesize = sysconf (_SC_PAGESIZE);
@@ -130,9 +131,12 @@ allocators_set_blocks (Allocators *self, Block *blocks)
for (b = blocks; b != NULL; b = b->next) {
Allocator *A = b->allocator;
- sum = allocators_store_get_sum (store, A->alloc_fn);
- if (sum == NULL)
- sum = allocators_store_new_sum (store, A->alloc_fn);
+ if (A != lastA) {
+ sum = allocators_store_get_sum (store, A->alloc_fn);
+ if (sum == NULL)
+ sum = allocators_store_new_sum (store, A->alloc_fn);
+ lastA = A;
+ }
if (b->addr < sum->min)
sum->min = b->addr;