Get rid of all dynamic_cast<>s while working on LTL formulae.
They are too slow. * src/ltlast/formula.hh (opkind, kind, kind_): Use an enum to indicate the actual kind of the formula. This way we can check the kind of a formula without relying on dynamic_cast. * src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc, src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/constant.cc, src/ltlast/multop.cc, src/ltlast/refformula.cc, src/ltlast/refformula.hh, src/ltlast/unop.cc: Adjust constructors. * src/ltlvisit/basicreduce.cc, src/ltlvisit/mark.cc, src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc: Replace all dynamic_cast by a call to kind() followed by a static_cast.
This commit is contained in:
parent
48cde88b9b
commit
957ba664b7
15 changed files with 743 additions and 609 deletions
|
|
@ -34,7 +34,7 @@ namespace spot
|
|||
namespace ltl
|
||||
{
|
||||
multop::multop(type op, vec* v)
|
||||
: op_(op), children_(v)
|
||||
: ref_formula(MultOp), op_(op), children_(v)
|
||||
{
|
||||
unsigned s = v->size();
|
||||
assert(s > 1);
|
||||
|
|
@ -177,26 +177,27 @@ namespace spot
|
|||
vec::iterator i = v->begin();
|
||||
while (i != v->end())
|
||||
{
|
||||
multop* p = dynamic_cast<multop*>(*i);
|
||||
if (p && p->op() == op)
|
||||
if ((*i)->kind() == MultOp)
|
||||
{
|
||||
unsigned ps = p->size();
|
||||
for (unsigned n = 0; n < ps; ++n)
|
||||
inlined.push_back(p->nth(n)->clone());
|
||||
(*i)->destroy();
|
||||
i = v->erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// All operator except "Concat" and "Fusion" are
|
||||
// commutative, so we just keep a list of the inlined
|
||||
// arguments that should later be added to the vector.
|
||||
// For concat we have to keep track of the order of
|
||||
// all the arguments.
|
||||
if (op == Concat || op == Fusion)
|
||||
inlined.push_back(*i);
|
||||
++i;
|
||||
multop* p = static_cast<multop*>(*i);
|
||||
if (p->op() == op)
|
||||
{
|
||||
unsigned ps = p->size();
|
||||
for (unsigned n = 0; n < ps; ++n)
|
||||
inlined.push_back(p->nth(n)->clone());
|
||||
(*i)->destroy();
|
||||
i = v->erase(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// All operator except "Concat" and "Fusion" are
|
||||
// commutative, so we just keep a list of the inlined
|
||||
// arguments that should later be added to the vector.
|
||||
// For concat we have to keep track of the order of
|
||||
// all the arguments.
|
||||
if (op == Concat || op == Fusion)
|
||||
inlined.push_back(*i);
|
||||
++i;
|
||||
}
|
||||
if (op == Concat || op == Fusion)
|
||||
*v = inlined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue