Commit 43ec36cd authored by Etienne Renault's avatar Etienne Renault

Prefer emplace_back to push_back

* spot/graph/ngraph.hh, spot/ltsmin/ltsmin.cc,
spot/misc/bitvect.hh, spot/misc/intvcomp.cc,
spot/misc/satsolver.cc, spot/priv/weight.cc,
spot/ta/taexplicit.cc, spot/taalgos/minimize.cc,
spot/taalgos/reachiter.cc, spot/tl/exclusive.cc,
spot/tl/formula.cc, spot/tl/formula.hh,
spot/tl/mark.cc, spot/tl/mutation.cc,
spot/tl/relabel.cc, spot/tl/remove_x.cc,
spot/tl/simplify.cc, spot/twa/acc.cc,
spot/twa/acc.hh, spot/twa/formula2bdd.cc,
spot/twa/taatgba.cc, spot/twa/taatgba.hh,
spot/twa/twa.hh, spot/twa/twagraph.cc,
spot/twaalgos/bfssteps.cc, spot/twaalgos/canonicalize.cc,
spot/twaalgos/compsusp.cc, spot/twaalgos/copy.cc,
spot/twaalgos/cycles.cc, spot/twaalgos/degen.cc,
spot/twaalgos/determinize.cc, spot/twaalgos/dtwasat.cc,
spot/twaalgos/emptiness.cc, spot/twaalgos/gv04.cc,
spot/twaalgos/hoa.cc, spot/twaalgos/ltl2taa.cc,
spot/twaalgos/ltl2tgba_fm.cc, spot/twaalgos/magic.cc,
spot/twaalgos/mask.hh, spot/twaalgos/minimize.cc,
spot/twaalgos/powerset.cc, spot/twaalgos/product.cc,
spot/twaalgos/randomgraph.cc, spot/twaalgos/reachiter.cc,
spot/twaalgos/relabel.cc, spot/twaalgos/remfin.cc,
spot/twaalgos/sccfilter.cc, spot/twaalgos/se05.cc,
spot/twaalgos/simulation.cc, spot/twaalgos/stutter.cc,
spot/twaalgos/tau03opt.cc, spot/twaalgos/totgba.cc,
spot/twaalgos/word.cc, tests/core/bitvect.cc: here.
parent ef214b2c
......@@ -144,7 +144,7 @@ namespace spot
std::vector<State_Name> d;
d.reserve(dst.size());
for (auto n: dst)
d.push_back(get_state(n));
d.emplace_back(get_state(n));
return g_.new_edge(get_state(src), d, std::forward<Args>(args)...);
}
......@@ -156,7 +156,7 @@ namespace spot
std::vector<state> d;
d.reserve(dst.size());
for (auto n: dst)
d.push_back(get_state(n));
d.emplace_back(get_state(n));
return g_.new_edge(get_state(src), d, std::forward<Args>(args)...);
}
};
......
......@@ -236,7 +236,7 @@ namespace spot
new(p->allocate()) spins_state(ctx->state_size, p);
memcpy(out->vars, dst, ctx->state_size * sizeof(int));
out->compute_hash();
ctx->transitions.push_back(out);
ctx->transitions.emplace_back(out);
}
void transition_callback_compress(void* arg, transition_info_t*, int *dst)
......@@ -252,7 +252,7 @@ namespace spot
spins_compressed_state* out = new(mem) spins_compressed_state(csize, p);
memcpy(out->vars, ctx->compressed, csize * sizeof(int));
out->compute_hash();
ctx->transitions.push_back(out);
ctx->transitions.emplace_back(out);
}
////////////////////////////////////////////////////////////////////////
......@@ -462,7 +462,7 @@ namespace spot
// Record that X.Y must be equal to Z.
int v = dict->register_proposition(*ap, d.get());
one_prop p = { ni->second.num, OP_EQ, ei->second, v };
out.push_back(p);
out.emplace_back(p);
free(name);
continue;
}
......@@ -473,7 +473,7 @@ namespace spot
{
int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, OP_NE, 0, v };
out.push_back(p);
out.emplace_back(p);
free(name);
continue;
}
......@@ -591,7 +591,7 @@ namespace spot
int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, op, val, v };
out.push_back(p);
out.emplace_back(p);
}
if (errors)
......@@ -809,7 +809,7 @@ namespace spot
// Add a self-loop to dead-states if we care about these.
if (res != bddfalse)
cc->transitions.push_back(st->clone());
cc->transitions.emplace_back(st->clone());
}
state_condition_last_cc_ = cc;
......@@ -861,7 +861,7 @@ namespace spot
// Add a self-loop to dead-states if we care about these.
if (t == 0 && scond != bddfalse)
cc->transitions.push_back(st->clone());
cc->transitions.emplace_back(st->clone());
}
if (iter_cache_)
......
......@@ -141,7 +141,7 @@ namespace spot
}
/// Append one bit.
void push_back(bool val)
void emplace_back(bool val)
{
if (size() == capacity())
grow();
......@@ -153,7 +153,7 @@ namespace spot
}
/// \brief Append the lowest \a count bits of \a data.
void push_back(block_t data, unsigned count)
void emplace_back(block_t data, unsigned count)
{
if (size() + count > capacity())
grow();
......@@ -417,18 +417,18 @@ namespace spot
{
block_t data = storage_[indexb];
data >>= bitb;
res->push_back(data, count);
res->emplace_back(data, count);
}
else
{
block_t data = storage_[indexb];
data >>= bitb;
res->push_back(data, bpb - bitb);
res->emplace_back(data, bpb - bitb);
count -= bpb - bitb;
while (count >= bpb)
{
++indexb;
res->push_back(storage_[indexb], bpb);
res->emplace_back(storage_[indexb], bpb);
count -= bpb;
SPOT_ASSERT(indexb != indexe || count == 0);
}
......@@ -437,7 +437,7 @@ namespace spot
++indexb;
SPOT_ASSERT(indexb == indexe);
SPOT_ASSERT(count == end % bpb);
res->push_back(storage_[indexb], count);
res->emplace_back(storage_[indexb], count);
}
}
return res;
......
......@@ -196,7 +196,7 @@ namespace spot
void push_data(unsigned int i)
{
result_->push_back(i);
result_->emplace_back(i);
}
const std::vector<unsigned int>*
......@@ -246,7 +246,7 @@ namespace spot
void push_data(unsigned int i)
{
output_.push_back(i);
output_.emplace_back(i);
}
bool have_data() const
......@@ -543,7 +543,7 @@ namespace spot
void push_data(int i)
{
prev_ = i;
result_.push_back(i);
result_.emplace_back(i);
--size_;
}
......@@ -551,7 +551,7 @@ namespace spot
{
size_ -= i;
while (i--)
result_.push_back(prev_);
result_.emplace_back(prev_);
}
bool have_comp_data() const
......
......@@ -108,7 +108,7 @@ namespace spot
{
if (i == 0)
goto done;
sol.push_back(i);
sol.emplace_back(i);
}
if (!in->eof())
// If we haven't reached end-of-file, then we just attempted
......
......@@ -52,7 +52,7 @@ namespace spot
std::vector<unsigned> res;
for (unsigned n = 0; n < max; ++n)
if (m[n] > w.m[n])
res.push_back(n);
res.emplace_back(n);
return acc_cond::mark_t(res.begin(), res.end());
}
......
......@@ -158,8 +158,8 @@ namespace spot
}
else
{
trans_by_condition->push_back(t);
transitions_->push_back(t);
trans_by_condition->emplace_back(t);
transitions_->emplace_back(t);
}
}
......
......@@ -266,7 +266,7 @@ namespace spot
{
hash_set* cI = new hash_set;
cI->insert(*i);
done.push_back(cI);
done.emplace_back(cI);
used_var[set_num] = 1;
free_var.erase(set_num);
......@@ -284,9 +284,9 @@ namespace spot
used_var[num] = s;
free_var.erase(num);
if (s > 1)
cur_run.push_back(G);
cur_run.emplace_back(G);
else
done.push_back(G);
done.emplace_back(G);
for (hash_set::const_iterator i = G->begin(); i != G->end(); ++i)
state_set_map[*i] = num;
......@@ -304,9 +304,9 @@ namespace spot
used_var[num] = s;
free_var.erase(num);
if (s > 1)
cur_run.push_back(F);
cur_run.emplace_back(F);
else
done.push_back(F);
done.emplace_back(F);
for (hash_set::const_iterator i = F->begin(); i != F->end(); ++i)
state_set_map[*i] = num;
}
......@@ -323,9 +323,9 @@ namespace spot
used_var[num] = s;
free_var.erase(num);
if (s > 1)
cur_run.push_back(G_F);
cur_run.emplace_back(G_F);
else
done.push_back(G_F);
done.emplace_back(G_F);
for (hash_set::const_iterator i = G_F->begin(); i != G_F->end(); ++i)
state_set_map[*i] = num;
}
......@@ -342,9 +342,9 @@ namespace spot
used_var[num] = s;
free_var.erase(num);
if (s > 1)
cur_run.push_back(S);
cur_run.emplace_back(S);
else
done.push_back(S);
done.emplace_back(S);
for (hash_set::const_iterator i = S->begin(); i != S->end(); ++i)
state_set_map[*i] = num;
}
......@@ -432,7 +432,7 @@ namespace spot
trace
<< "set " << format_hash_set(bsi->second, ta_)
<< " was not split" << std::endl;
next_run.push_back(bsi->second);
next_run.emplace_back(bsi->second);
}
else
{
......@@ -466,14 +466,14 @@ namespace spot
trace
<< "set " << format_hash_set(set, ta_)
<< " is minimal" << std::endl;
done.push_back(set);
done.emplace_back(set);
}
else
{
trace
<< "set " << format_hash_set(set, ta_)
<< " should be processed further" << std::endl;
next_run.push_back(set);
next_run.emplace_back(set);
}
}
}
......
......@@ -167,7 +167,7 @@ namespace spot
void
ta_reachable_iterator_breadth_first::add_state(const state* s)
{
todo.push_back(s);
todo.emplace_back(s);
}
const state*
......
......@@ -104,7 +104,7 @@ namespace spot
void exclusive_ap::add_group(std::vector<formula> ap)
{
groups.push_back(ap);
groups.emplace_back(ap);
}
namespace
......@@ -130,12 +130,12 @@ namespace spot
for (auto ap: g)
if (s->find(ap) != s->end())
group.push_back(ap);
group.emplace_back(ap);
unsigned s = group.size();
for (unsigned j = 0; j < s; ++j)
for (unsigned k = j + 1; k < s; ++k)
v.push_back(nand(group[j], group[k]));
v.emplace_back(nand(group[j], group[k]));
};
delete s;
......@@ -166,7 +166,7 @@ namespace spot
{
int v = d->has_registered_proposition(ap, aut);
if (v >= 0)
group.push_back(bdd_nithvar(v));
group.emplace_back(bdd_nithvar(v));
}
unsigned s = group.size();
......
......@@ -105,7 +105,7 @@ namespace spot
{
if ((*i)->is_boolean())
{
b.push_back(*i);
b.emplace_back(*i);
i = v.erase(i);
}
else
......@@ -230,7 +230,7 @@ namespace spot
{
unsigned ps = (*i)->size();
for (unsigned n = 0; n < ps; ++n)
inlined.push_back((*i)->nth(n)->clone());
inlined.emplace_back((*i)->nth(n)->clone());
(*i)->destroy();
// FIXME: Do not use erase. See previous FIXME.
i = v.erase(i);
......@@ -242,7 +242,7 @@ namespace spot
// For concat we have to keep track of the order of
// all the arguments.
if (o == op::Concat || o == op::Fusion)
inlined.push_back(*i);
inlined.emplace_back(*i);
++i;
}
if (o == op::Concat || o == op::Fusion)
......@@ -470,10 +470,10 @@ namespace spot
i->destroy();
continue;
}
tmp.push_back(i);
tmp.emplace_back(i);
}
if (tmp.empty())
tmp.push_back(weak_abs);
tmp.emplace_back(weak_abs);
v.swap(tmp);
}
}
......@@ -1624,7 +1624,7 @@ namespace spot
v.reserve(s - 1);
for (unsigned j = 0; j < s; ++j)
if (i != j)
v.push_back(nth(j)->clone());
v.emplace_back(nth(j)->clone());
return multop(o, v);
}
default:
......
......@@ -1018,7 +1018,7 @@ namespace spot
tmp.reserve(l.size());
for (auto f: l)
if (f.ptr_)
tmp.push_back(f.ptr_->clone());
tmp.emplace_back(f.ptr_->clone());
return formula(fnode::multop(o, std::move(tmp)));
}
......@@ -1029,7 +1029,7 @@ namespace spot
tmp.reserve(l.size());
for (auto f: l)
if (f.ptr_)
tmp.push_back(f.to_node_());
tmp.emplace_back(f.to_node_());
return formula(fnode::multop(o, std::move(tmp)));
}
#endif // !SWIG
......@@ -1628,7 +1628,7 @@ namespace spot
std::vector<formula> tmp;
tmp.reserve(size());
for (auto f: *this)
tmp.push_back(trans(f));
tmp.emplace_back(trans(f));
return multop(o, std::move(tmp));
}
case op::Star:
......
......@@ -137,24 +137,24 @@ namespace spot
if (c.is(op::EConcatMarked))
{
empairs.emplace(c[0], c[1]);
v.push_back(c.map(recurse));
v.emplace_back(c.map(recurse));
}
else if (c.is(op::EConcat))
{
elist.push_back(c);
elist.emplace_back(c);
}
else if (c.is(op::NegClosureMarked))
{
nmset.insert(c[0]);
v.push_back(c.map(recurse));
v.emplace_back(c.map(recurse));
}
else if (c.is(op::NegClosure))
{
nlist.push_back(c);
nlist.emplace_back(c);
}
else
{
v.push_back(c);
v.emplace_back(c);
}
}
// Keep only the non-marked EConcat for which we
......@@ -162,12 +162,12 @@ namespace spot
for (auto e: elist)
if (empairs.find(std::make_pair(e[0], e[1]))
== empairs.end())
v.push_back(e);
v.emplace_back(e);
// Keep only the non-marked NegClosure for which we
// have not seen a similar NegClosureMarked.
for (auto n: nlist)
if (nmset.find(n[0]) == nmset.end())
v.push_back(n);
v.emplace_back(n);
res = formula::And(v);
}
break;
......
......@@ -116,7 +116,7 @@ namespace spot
{
vec v1;
vec v2;
v1.push_back(f[0]);
v1.emplace_back(f[0]);
bool reverse = false;
int i = 1;
while (i < mos)
......@@ -128,10 +128,10 @@ namespace spot
reverse = true;
break;
}
v1.push_back(f[i++]);
v1.emplace_back(f[i++]);
}
for (; i < mos; ++i)
v2.push_back(f[i]);
v2.emplace_back(f[i]);
formula first = AndNLM_(v1);
formula second = AndNLM_(v2);
formula ost = formula::one_star();
......
......@@ -253,8 +253,8 @@ namespace spot
if (!s.empty())
{
formula top = s.top();
in.first->second.push_back(top);
g[top].push_back(f);
in.first->second.emplace_back(top);
g[top].emplace_back(f);
if (!in.second)
return;
}
......@@ -291,10 +291,10 @@ namespace spot
// Note that we only add an edge in one
// direction, because we are building a cycle
// between all children anyway.
g[pred].push_back(next);
g[pred].emplace_back(next);
pred = next;
}
g[pred].push_back(f[0]);
g[pred].emplace_back(f[0]);
}
s.pop();
}
......@@ -436,7 +436,7 @@ namespace spot
if (b && b != f)
{
res.reserve(sz - i + 1);
res.push_back(visit(b));
res.emplace_back(visit(b));
}
else
{
......@@ -444,7 +444,7 @@ namespace spot
res.reserve(sz);
}
for (; i < sz; ++i)
res.push_back(visit(f[i]));
res.emplace_back(visit(f[i]));
return formula::multop(f.kind(), res);
}
};
......
......@@ -47,8 +47,8 @@ namespace spot
// First line
std::vector<formula> va1;
formula npi = formula::Not(i);
va1.push_back(i);
va1.push_back(formula::U(i, formula::And({npi, c})));
va1.emplace_back(i);
va1.emplace_back(formula::U(i, formula::And({npi, c})));
for (auto j: aps)
if (j != i)
......@@ -56,22 +56,22 @@ namespace spot
// make sure the arguments of OR are created in a
// deterministic order
auto tmp = formula::U(formula::Not(j), npi);
va1.push_back(formula::Or({formula::U(j, npi), tmp}));
va1.emplace_back(formula::Or({formula::U(j, npi), tmp}));
}
vo.push_back(formula::And(va1));
vo.emplace_back(formula::And(va1));
// Second line
std::vector<formula> va2;
va2.push_back(npi);
va2.push_back(formula::U(npi, formula::And({i, c})));
va2.emplace_back(npi);
va2.emplace_back(formula::U(npi, formula::And({i, c})));
for (auto j: aps)
if (j != i)
{
// make sure the arguments of OR are created in a
// deterministic order
auto tmp = formula::U(formula::Not(j), i);
va2.push_back(formula::Or({formula::U(j, i), tmp}));
va2.emplace_back(formula::Or({formula::U(j, i), tmp}));
}
vo.push_back(formula::And(va2));
vo.emplace_back(formula::And(va2));
}
// Third line
std::vector<formula> va3;
......@@ -80,10 +80,10 @@ namespace spot
// make sure the arguments of OR are created in a
// deterministic order
auto tmp = formula::G(formula::Not(i));
va3.push_back(formula::Or({formula::G(i), tmp}));
va3.emplace_back(formula::Or({formula::G(i), tmp}));
}
va3.push_back(c);
vo.push_back(formula::And(va3));
va3.emplace_back(c);
vo.emplace_back(formula::And(va3));
return formula::Or(vo);
}
}
......
This diff is collapsed.
......@@ -519,7 +519,7 @@ namespace spot
}
}
for (auto i: p)
pairs.push_back(i.second);
pairs.emplace_back(i.second);
return (!(seen_fin & seen_inf)
&& (seen_fin | seen_inf) == all_sets());
}
......@@ -568,7 +568,7 @@ namespace spot
codes.reserve(n_accs);
for (unsigned i = 0; i < n_accs; ++i)
{
codes.push_back(drand() < 0.5 ? inf({i}) : fin({i}));
codes.emplace_back(drand() < 0.5 ? inf({i}) : fin({i}));
if (reuse > 0.0 && drand() < reuse)
--i;
}
......@@ -664,9 +664,9 @@ namespace spot
std::vector<bdd> r;
for (unsigned i = 0; r.size() < umax; ++i)
if (used.has(i))
r.push_back(bdd_ithvar(base++));
r.emplace_back(bdd_ithvar(base++));
else
r.push_back(bddfalse);
r.emplace_back(bddfalse);
return to_bdd_rec(&lhs.back(), &r[0]) == to_bdd_rec(&rhs.back(), &r[0]);
}
}
......@@ -740,11 +740,11 @@ namespace spot
if (used.has(i))
{
sets[base] = i;
r.push_back(bdd_ithvar(base++));
r.emplace_back(bdd_ithvar(base++));
}
else
{
r.push_back(bddfalse);
r.emplace_back(bddfalse);
}
}