From 9cfc40826296557752ef765d82789c575c2d616d Mon Sep 17 00:00:00 2001 From: Pierre PARUTTO Date: Thu, 5 Apr 2012 17:47:38 +0200 Subject: [PATCH] Modify is_accepting sba's method to run in constant time. * src/tgba/tgbaexplicit.hh: modify is_accepting method --- src/tgba/tgbaexplicit.hh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/tgba/tgbaexplicit.hh b/src/tgba/tgbaexplicit.hh index 296ad538e..0539b5f9d 100644 --- a/src/tgba/tgbaexplicit.hh +++ b/src/tgba/tgbaexplicit.hh @@ -721,21 +721,24 @@ namespace spot { } + /// Assume that an accepting state has only accepting output transitions + /// So we need only to check one to decide virtual bool is_accepting(const spot::state* s) const { - bdd acc = bddtrue; - bool transition = false; - tgba_explicit_succ_iterator* it = this->succ_iter(s); - for (it->first(); !it->done() && acc != bddfalse; it->next()) + it->first(); + + // no transition + if (it->done()) { - transition = true; - acc &= it->current_acceptance_conditions(); + delete it; + return false; } + bool res = it->current_acceptance_conditions() != bddfalse; delete it; - return acc != bddfalse && transition; + return res; } private: