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:
Alexandre Duret-Lutz 2010-12-09 13:19:44 +01:00
parent 48cde88b9b
commit 957ba664b7
15 changed files with 743 additions and 609 deletions

View file

@ -71,11 +71,20 @@ namespace spot
class formula
{
public:
formula() : count_(max_count++)
/// Kind of a sub-formula
enum opkind { Constant,
AtomicProp,
UnOp,
BinOp,
MultOp,
BUnOp,
AutomatOp };
formula(opkind k) : count_(max_count++), kind_(k)
{
// If the counter of formulae ever loops, we want to skip the
// first three values, because they are permanently associated
// to constants, and its convenient to have constants smaller
// to constants, and it is convenient to have constants smaller
// than all other formulae.
if (max_count == 0)
max_count = 3;
@ -100,6 +109,12 @@ namespace spot
/// Return a canonic representation of the formula
virtual std::string dump() const = 0;
/// Return the kind of the top-level operator.
opkind kind() const
{
return kind_;
}
////////////////
// Properties //
////////////////
@ -279,6 +294,7 @@ namespace spot
private:
/// \brief Number of formulae created so far.
static size_t max_count;
opkind kind_;
};
/// \brief Strict Weak Ordering for <code>const formula*</code>.