* eina: easy speed improvement by reducing operation of mempool.

SVN revision: 53349
This commit is contained in:
Cedric BAIL 2010-10-13 12:12:45 +00:00
parent a1c4588d64
commit a44992380f
1 changed files with 22 additions and 19 deletions

View File

@ -218,28 +218,31 @@ eina_chained_mempool_free(void *data, void *ptr)
EINA_INLIST_FOREACH(pool->first, p) EINA_INLIST_FOREACH(pool->first, p)
{ {
// pool mem base // Could the pointer be inside that pool
pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool)); if (ptr < p->limit)
// is it in pool mem?
if ((ptr >= pmem) &&
((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
{ {
// freed node points to prev free node // pool mem base
eina_trash_push(&p->base, ptr); pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
// next free node is now the one we freed // is it in pool mem?
p->usage--; if (ptr >= pmem)
pool->usage--;
if (p->usage == 0)
{ {
// free bucket // freed node points to prev free node
pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p)); eina_trash_push(&p->base, ptr);
_eina_chained_mp_pool_free(p); // next free node is now the one we freed
} p->usage--;
else pool->usage--;
// move to front if (p->usage == 0)
pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p)); {
// free bucket
pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
_eina_chained_mp_pool_free(p);
}
else
// move to front
pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
break; break;
}
} }
} }