twa: Use generic accepting run search

Make use of the generic accepting run search in twa::accepting_run()
and twa::accepting_word().

* spot/twa/twa.cc: Here.
This commit is contained in:
Clément Gillard 2019-02-06 11:45:09 +01:00 committed by Alexandre Duret-Lutz
parent 51ca5ecdb1
commit 837f9e296b

View file

@ -104,11 +104,10 @@ namespace spot
twa_run_ptr twa_run_ptr
twa::accepting_run() const twa::accepting_run() const
{ {
if (acc().uses_fin_acceptance()) const_twa_ptr a = shared_from_this();
throw std::runtime_error("twa::accepting_run() does not work with " if (const_twa_graph_ptr ag = fin_to_twa_graph_maybe(a))
"Fin acceptance (but twa::is_empty() and " return generic_accepting_run(ag);
"twa::accepting_word() can)"); auto res = couvreur99_new_check(a);
auto res = couvreur99_new_check(shared_from_this());
if (!res) if (!res)
return nullptr; return nullptr;
return res->accepting_run(); return res->accepting_run();
@ -117,7 +116,7 @@ namespace spot
twa_word_ptr twa_word_ptr
twa::accepting_word() const twa::accepting_word() const
{ {
if (auto run = remove_fin_maybe(shared_from_this())->accepting_run()) if (auto run = shared_from_this()->accepting_run())
{ {
auto w = make_twa_word(run->reduce()); auto w = make_twa_word(run->reduce());
w->simplify(); w->simplify();