[buddy] Inline the "is bdd constant" check performed in copies/constructors.

This avoids a library call to bdd_addref or bdd_delref.

* src/kernel.c (bdd_delref_nc, bdd_addref_nc): New function,
that work only on BDD that are not constant.
* src/cpext.cxx (bdd::operator=): Move...
* src/bdd.hh (bdd::operator=): ... here.
(bdd::bdd, bdd::~bdd, bdd::operator=): Inline the "is bdd constant"
check and call bdd_delref_nc/bdd_addref_nc only otherwise.
This commit is contained in:
Alexandre Duret-Lutz 2011-04-30 13:37:53 +02:00
parent 2b58fb90c4
commit 1d1872ab90
4 changed files with 104 additions and 59 deletions

View file

@ -1102,6 +1102,20 @@ void bdd_gbc(void)
}
BDD bdd_addref_nc(BDD root)
{
#ifndef NDEBUG
if (!bddrunning)
return root;
if (root < 2 || root >= bddnodesize)
return bdd_error(BDD_ILLBDD);
if (LOW(root) == -1)
return bdd_error(BDD_ILLBDD);
#endif
INCREF(root);
return root;
}
/*
NAME {* bdd\_addref *}
SECTION {* kernel *}
@ -1131,6 +1145,23 @@ BDD bdd_addref(BDD root)
return root;
}
// Non constant version
BDD bdd_delref_nc(BDD root)
{
#ifndef NDEBUG
if (root < 2 || !bddrunning)
return root;
if (root >= bddnodesize)
return bdd_error(BDD_ILLBDD);
if (LOW(root) == -1)
return bdd_error(BDD_ILLBDD);
/* if the following line is present, fails there much earlier */
if (!HASREF(root)) bdd_error(BDD_BREAK); /* distinctive */
#endif
DECREF(root);
return root;
}
/*
NAME {* bdd\_delref *}