avoid mark_t::count() when possible

count() may be implemented using a loop, so using it touch
check count() == 1 or count() > 1 is not advisable.

* spot/twa/acc.hh (mark_t::is_singleton, mark_t::has_many): Introduce
these two methods to replace count()==1 and count()>1
* spot/twa/acc.cc, spot/twaalgos/cleanacc.cc,
spot/twaalgos/determinize.cc, spot/twaalgos/dtwasat.cc,
spot/twaalgos/iscolored.cc, spot/twaalgos/remfin.cc,
spot/twaalgos/toparity.cc: Adjust usage.
This commit is contained in:
Alexandre Duret-Lutz 2020-04-18 23:23:44 +02:00
parent c0e1b3e52a
commit cc12d514be
8 changed files with 219 additions and 197 deletions

View file

@ -177,7 +177,7 @@ namespace spot
auto tmp = remove_compl_rec(pos, complement);
if (!tmp.empty() && (tmp.back().sub.op == opfin
&& tmp.front().mark.count() == 1))
&& tmp.front().mark.is_singleton()))
seen_fin |= tmp.front().mark;
if (opand == acc_cond::acc_op::And)
@ -390,7 +390,7 @@ namespace spot
case acc_cond::acc_op::FinNeg:
{
auto m = pos[-1].mark;
if (op == wanted && m == m.lowest())
if (op == wanted && m.is_singleton())
{
res |= m;
}
@ -427,7 +427,7 @@ namespace spot
if (op == wanted)
{
auto m = pos[-1].mark;
if (!seen && m == m.lowest())
if (!seen && m.is_singleton())
{
seen = true;
res |= m;
@ -513,7 +513,7 @@ namespace spot
case acc_cond::acc_op::Fin:
{
auto m = pos[-1].mark;
if (op == wanted && m == m.lowest())
if (op == wanted && m.is_singleton())
singletons.emplace_back(m, pos);
pos -= 2;
}
@ -550,8 +550,8 @@ namespace spot
if (!can_receive)
return;
for (auto p: singletons)
if (p.first != can_receive &&
p.first.lowest() == p.first)
if (p.first != can_receive
&& p.first.is_singleton())
{
// Mark fused singletons as false,
// so that a future call to
@ -596,7 +596,7 @@ namespace spot
for (auto pair: to_fuse)
if (pair.first & once) // can we remove pair.first?
{
assert(pair.first.count() == 1);
assert(pair.first.is_singleton());
for (auto& e: aut->edges())
if (e.acc & pair.first)
e.acc = (e.acc - pair.first) | pair.second;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015-2019 Laboratoire de Recherche et
// Copyright (C) 2015-2020 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -195,7 +195,7 @@ namespace spot
int newb = brace;
if (acc)
{
assert(acc.has(0) && acc.count() == 1 && "Only TBA are accepted");
assert(acc.has(0) && acc.is_singleton() && "Only TBA are accepted");
// Accepting edges generate new braces: step A1
newb = braces_.size();
braces_.emplace_back(brace);

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013-2019 Laboratoire de Recherche
// Copyright (C) 2013-2020 Laboratoire de Recherche
// et Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -153,7 +153,7 @@ namespace spot
break;
case acc_cond::acc_op::Fin:
fin |= pos[-1].mark;
assert(pos[-1].mark.count() == 1);
assert(pos[-1].mark.is_singleton());
pos -= 2;
break;
case acc_cond::acc_op::Inf:

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2017-2018, 2020 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -26,7 +26,7 @@ namespace spot
is_colored(const const_twa_graph_ptr& aut)
{
for (auto t: aut->edges())
if (t.acc.count() != 1)
if (!t.acc.is_singleton())
return false;
return true;
}

View file

@ -356,7 +356,7 @@ namespace spot
break;
case acc_cond::acc_op::Fin:
fin |= pos[-1].mark;
assert(pos[-1].mark.count() == 1);
assert(pos[-1].mark.is_singleton());
pos -= 2;
break;
case acc_cond::acc_op::Inf:

View file

@ -660,7 +660,7 @@ get_inputs_states(const twa_graph_ptr& aut)
for (auto e : aut->edges())
{
auto elements = e.acc & used;
if (elements.count() > 1)
if (elements.has_many())
inputs[e.dst].insert(elements);
}
return inputs;