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
|
|
@ -33,13 +33,13 @@ namespace spot
|
|||
namespace ltl
|
||||
{
|
||||
unop::unop(type op, formula* child)
|
||||
: op_(op), child_(child)
|
||||
: ref_formula(UnOp), op_(op), child_(child)
|
||||
{
|
||||
props = child->get_props();
|
||||
switch (op)
|
||||
{
|
||||
case Not:
|
||||
is.in_nenoform = !!dynamic_cast<atomic_prop*>(child);
|
||||
is.in_nenoform = (child->kind() == AtomicProp);
|
||||
is.accepting_eword = false;
|
||||
break;
|
||||
case X:
|
||||
|
|
@ -163,10 +163,13 @@ namespace spot
|
|||
case F:
|
||||
case G:
|
||||
{
|
||||
// F and G are idempotent.
|
||||
unop* u = dynamic_cast<unop*>(child);
|
||||
if (u && u->op() == op)
|
||||
return u;
|
||||
if (child->kind() == UnOp)
|
||||
{
|
||||
// F and G are idempotent.
|
||||
unop* u = static_cast<unop*>(child);
|
||||
if (u->op() == op)
|
||||
return u;
|
||||
}
|
||||
|
||||
// F(0) = G(0) = 0
|
||||
// F(1) = G(1) = 1
|
||||
|
|
@ -191,9 +194,9 @@ namespace spot
|
|||
return bunop::instance(bunop::Star,
|
||||
constant::true_instance(), 1);
|
||||
|
||||
unop* u = dynamic_cast<unop*>(child);
|
||||
if (u)
|
||||
if (child->kind() == UnOp)
|
||||
{
|
||||
unop* u = static_cast<unop*>(child);
|
||||
// "Not" is an involution.
|
||||
if (u->op() == op)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue