[buddy] pack cache entry on 16 bytes, not 20.

The double result is never used with a triple keys,
so we can pack the cache entry more tightly.

* src/cache.h: Reorganize the cache entry the structure.
* src/cache.c: Cleanup the code while we are at it.
* src/bddop.c: Adjust to accesses to cache entries.
This commit is contained in:
Alexandre Duret-Lutz 2014-10-28 09:57:55 +01:00
parent c189875daf
commit 971788fdbe
3 changed files with 119 additions and 129 deletions

View file

@ -35,6 +35,7 @@
DATE: (C) june 1997
*************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "cache.h"
#include "prime.h"
@ -42,19 +43,22 @@
/*************************************************************************
*************************************************************************/
void BddCache_reset(BddCache *cache)
{
int n;
for (n = 0; n < cache->tablesize; n++)
cache->table[n].i.a = -1;
}
int BddCache_init(BddCache *cache, int size)
{
int n;
size = bdd_prime_gte(size);
if ((cache->table=NEW(BddCacheData,size)) == NULL)
return bdd_error(BDD_MEMORY);
for (n=0 ; n<size ; n++)
cache->table[n].a = -1;
cache->tablesize = size;
BddCache_reset(cache);
return 0;
}
@ -69,29 +73,10 @@ void BddCache_done(BddCache *cache)
int BddCache_resize(BddCache *cache, int newsize)
{
int n;
free(cache->table);
newsize = bdd_prime_gte(newsize);
if ((cache->table=NEW(BddCacheData,newsize)) == NULL)
return bdd_error(BDD_MEMORY);
for (n=0 ; n<newsize ; n++)
cache->table[n].a = -1;
cache->tablesize = newsize;
return 0;
return BddCache_init(cache, newsize);
}
void BddCache_reset(BddCache *cache)
{
register int n;
for (n=0 ; n<cache->tablesize ; n++)
cache->table[n].a = -1;
}
/* EOF */