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 ...@@ -144,7 +144,7 @@ namespace spot
std::vector<State_Name> d; std::vector<State_Name> d;
d.reserve(dst.size()); d.reserve(dst.size());
for (auto n: dst) 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)...); return g_.new_edge(get_state(src), d, std::forward<Args>(args)...);
} }
...@@ -156,7 +156,7 @@ namespace spot ...@@ -156,7 +156,7 @@ namespace spot
std::vector<state> d; std::vector<state> d;
d.reserve(dst.size()); d.reserve(dst.size());
for (auto n: dst) 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)...); return g_.new_edge(get_state(src), d, std::forward<Args>(args)...);
} }
}; };
......
...@@ -236,7 +236,7 @@ namespace spot ...@@ -236,7 +236,7 @@ namespace spot
new(p->allocate()) spins_state(ctx->state_size, p); new(p->allocate()) spins_state(ctx->state_size, p);
memcpy(out->vars, dst, ctx->state_size * sizeof(int)); memcpy(out->vars, dst, ctx->state_size * sizeof(int));
out->compute_hash(); out->compute_hash();
ctx->transitions.push_back(out); ctx->transitions.emplace_back(out);
} }
void transition_callback_compress(void* arg, transition_info_t*, int *dst) void transition_callback_compress(void* arg, transition_info_t*, int *dst)
...@@ -252,7 +252,7 @@ namespace spot ...@@ -252,7 +252,7 @@ namespace spot
spins_compressed_state* out = new(mem) spins_compressed_state(csize, p); spins_compressed_state* out = new(mem) spins_compressed_state(csize, p);
memcpy(out->vars, ctx->compressed, csize * sizeof(int)); memcpy(out->vars, ctx->compressed, csize * sizeof(int));
out->compute_hash(); out->compute_hash();
ctx->transitions.push_back(out); ctx->transitions.emplace_back(out);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -462,7 +462,7 @@ namespace spot ...@@ -462,7 +462,7 @@ namespace spot
// Record that X.Y must be equal to Z. // Record that X.Y must be equal to Z.
int v = dict->register_proposition(*ap, d.get()); int v = dict->register_proposition(*ap, d.get());
one_prop p = { ni->second.num, OP_EQ, ei->second, v }; one_prop p = { ni->second.num, OP_EQ, ei->second, v };
out.push_back(p); out.emplace_back(p);
free(name); free(name);
continue; continue;
} }
...@@ -473,7 +473,7 @@ namespace spot ...@@ -473,7 +473,7 @@ namespace spot
{ {
int v = dict->register_proposition(*ap, d); int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, OP_NE, 0, v }; one_prop p = { var_num, OP_NE, 0, v };
out.push_back(p); out.emplace_back(p);
free(name); free(name);
continue; continue;
} }
...@@ -591,7 +591,7 @@ namespace spot ...@@ -591,7 +591,7 @@ namespace spot
int v = dict->register_proposition(*ap, d); int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, op, val, v }; one_prop p = { var_num, op, val, v };
out.push_back(p); out.emplace_back(p);
} }
if (errors) if (errors)
...@@ -809,7 +809,7 @@ namespace spot ...@@ -809,7 +809,7 @@ namespace spot
// Add a self-loop to dead-states if we care about these. // Add a self-loop to dead-states if we care about these.
if (res != bddfalse) if (res != bddfalse)
cc->transitions.push_back(st->clone()); cc->transitions.emplace_back(st->clone());
} }
state_condition_last_cc_ = cc; state_condition_last_cc_ = cc;
...@@ -861,7 +861,7 @@ namespace spot ...@@ -861,7 +861,7 @@ namespace spot
// Add a self-loop to dead-states if we care about these. // Add a self-loop to dead-states if we care about these.
if (t == 0 && scond != bddfalse) if (t == 0 && scond != bddfalse)
cc->transitions.push_back(st->clone()); cc->transitions.emplace_back(st->clone());
} }
if (iter_cache_) if (iter_cache_)
......
...@@ -141,7 +141,7 @@ namespace spot ...@@ -141,7 +141,7 @@ namespace spot
} }
/// Append one bit. /// Append one bit.
void push_back(bool val) void emplace_back(bool val)
{ {
if (size() == capacity()) if (size() == capacity())
grow(); grow();
...@@ -153,7 +153,7 @@ namespace spot ...@@ -153,7 +153,7 @@ namespace spot
} }
/// \brief Append the lowest \a count bits of \a data. /// \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()) if (size() + count > capacity())
grow(); grow();
...@@ -417,18 +417,18 @@ namespace spot ...@@ -417,18 +417,18 @@ namespace spot
{ {
block_t data = storage_[indexb]; block_t data = storage_[indexb];
data >>= bitb; data >>= bitb;
res->push_back(data, count); res->emplace_back(data, count);
} }
else else
{ {
block_t data = storage_[indexb]; block_t data = storage_[indexb];
data >>= bitb; data >>= bitb;
res->push_back(data, bpb - bitb); res->emplace_back(data, bpb - bitb);
count -= bpb - bitb; count -= bpb - bitb;
while (count >= bpb) while (count >= bpb)
{ {
++indexb; ++indexb;
res->push_back(storage_[indexb], bpb); res->emplace_back(storage_[indexb], bpb);
count -= bpb; count -= bpb;
SPOT_ASSERT(indexb != indexe || count == 0); SPOT_ASSERT(indexb != indexe || count == 0);
} }
...@@ -437,7 +437,7 @@ namespace spot ...@@ -437,7 +437,7 @@ namespace spot
++indexb; ++indexb;
SPOT_ASSERT(indexb == indexe); SPOT_ASSERT(indexb == indexe);
SPOT_ASSERT(count == end % bpb); SPOT_ASSERT(count == end % bpb);
res->push_back(storage_[indexb], count); res->emplace_back(storage_[indexb], count);
} }
} }
return res; return res;
......
...@@ -196,7 +196,7 @@ namespace spot ...@@ -196,7 +196,7 @@ namespace spot
void push_data(unsigned int i) void push_data(unsigned int i)
{ {
result_->push_back(i); result_->emplace_back(i);
} }
const std::vector<unsigned int>* const std::vector<unsigned int>*
...@@ -246,7 +246,7 @@ namespace spot ...@@ -246,7 +246,7 @@ namespace spot
void push_data(unsigned int i) void push_data(unsigned int i)
{ {
output_.push_back(i); output_.emplace_back(i);
} }
bool have_data() const bool have_data() const
...@@ -543,7 +543,7 @@ namespace spot ...@@ -543,7 +543,7 @@ namespace spot
void push_data(int i) void push_data(int i)
{ {
prev_ = i; prev_ = i;
result_.push_back(i); result_.emplace_back(i);
--size_; --size_;
} }
...@@ -551,7 +551,7 @@ namespace spot ...@@ -551,7 +551,7 @@ namespace spot
{ {
size_ -= i; size_ -= i;
while (i--) while (i--)
result_.push_back(prev_); result_.emplace_back(prev_);
} }
bool have_comp_data() const bool have_comp_data() const
......
...@@ -108,7 +108,7 @@ namespace spot ...@@ -108,7 +108,7 @@ namespace spot
{ {
if (i == 0) if (i == 0)
goto done; goto done;
sol.push_back(i); sol.emplace_back(i);
} }
if (!in->eof()) if (!in->eof())
// If we haven't reached end-of-file, then we just attempted // If we haven't reached end-of-file, then we just attempted
......
...@@ -52,7 +52,7 @@ namespace spot ...@@ -52,7 +52,7 @@ namespace spot
std::vector<unsigned> res; std::vector<unsigned> res;
for (unsigned n = 0; n < max; ++n) for (unsigned n = 0; n < max; ++n)
if (m[n] > w.m[n]) if (m[n] > w.m[n])
res.push_back(n); res.emplace_back(n);
return acc_cond::mark_t(res.begin(), res.end()); return acc_cond::mark_t(res.begin(), res.end());
} }
......
...@@ -158,8 +158,8 @@ namespace spot ...@@ -158,8 +158,8 @@ namespace spot
} }
else else
{ {
trans_by_condition->push_back(t); trans_by_condition->emplace_back(t);
transitions_->push_back(t); transitions_->emplace_back(t);
} }
} }
......
...@@ -266,7 +266,7 @@ namespace spot ...@@ -266,7 +266,7 @@ namespace spot
{ {
hash_set* cI = new hash_set; hash_set* cI = new hash_set;
cI->insert(*i); cI->insert(*i);
done.push_back(cI); done.emplace_back(cI);
used_var[set_num] = 1; used_var[set_num] = 1;
free_var.erase(set_num); free_var.erase(set_num);
...@@ -284,9 +284,9 @@ namespace spot ...@@ -284,9 +284,9 @@ namespace spot
used_var[num] = s; used_var[num] = s;
free_var.erase(num); free_var.erase(num);
if (s > 1) if (s > 1)
cur_run.push_back(G); cur_run.emplace_back(G);
else else
done.push_back(G); done.emplace_back(G);
for (hash_set::const_iterator i = G->begin(); i != G->end(); ++i) for (hash_set::const_iterator i = G->begin(); i != G->end(); ++i)
state_set_map[*i] = num; state_set_map[*i] = num;
...@@ -304,9 +304,9 @@ namespace spot ...@@ -304,9 +304,9 @@ namespace spot
used_var[num] = s; used_var[num] = s;
free_var.erase(num); free_var.erase(num);
if (s > 1) if (s > 1)
cur_run.push_back(F); cur_run.emplace_back(F);
else else
done.push_back(F); done.emplace_back(F);
for (hash_set::const_iterator i = F->begin(); i != F->end(); ++i) for (hash_set::const_iterator i = F->begin(); i != F->end(); ++i)
state_set_map[*i] = num; state_set_map[*i] = num;
} }
...@@ -323,9 +323,9 @@ namespace spot ...@@ -323,9 +323,9 @@ namespace spot
used_var[num] = s; used_var[num] = s;
free_var.erase(num); free_var.erase(num);
if (s > 1) if (s > 1)
cur_run.push_back(G_F); cur_run.emplace_back(G_F);
else 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) for (hash_set::const_iterator i = G_F->begin(); i != G_F->end(); ++i)
state_set_map[*i] = num; state_set_map[*i] = num;
} }
...@@ -342,9 +342,9 @@ namespace spot ...@@ -342,9 +342,9 @@ namespace spot
used_var[num] = s; used_var[num] = s;
free_var.erase(num); free_var.erase(num);
if (s > 1) if (s > 1)
cur_run.push_back(S); cur_run.emplace_back(S);
else else
done.push_back(S); done.emplace_back(S);
for (hash_set::const_iterator i = S->begin(); i != S->end(); ++i) for (hash_set::const_iterator i = S->begin(); i != S->end(); ++i)
state_set_map[*i] = num; state_set_map[*i] = num;
} }
...@@ -432,7 +432,7 @@ namespace spot ...@@ -432,7 +432,7 @@ namespace spot
trace trace
<< "set " << format_hash_set(bsi->second, ta_) << "set " << format_hash_set(bsi->second, ta_)
<< " was not split" << std::endl; << " was not split" << std::endl;
next_run.push_back(bsi->second); next_run.emplace_back(bsi->second);
} }
else else
{ {
...@@ -466,14 +466,14 @@ namespace spot ...@@ -466,14 +466,14 @@ namespace spot
trace trace
<< "set " << format_hash_set(set, ta_) << "set " << format_hash_set(set, ta_)
<< " is minimal" << std::endl; << " is minimal" << std::endl;
done.push_back(set); done.emplace_back(set);
} }
else else
{ {
trace trace
<< "set " << format_hash_set(set, ta_) << "set " << format_hash_set(set, ta_)
<< " should be processed further" << std::endl; << " should be processed further" << std::endl;
next_run.push_back(set); next_run.emplace_back(set);
} }
} }
} }
......
...@@ -167,7 +167,7 @@ namespace spot ...@@ -167,7 +167,7 @@ namespace spot
void void
ta_reachable_iterator_breadth_first::add_state(const state* s) ta_reachable_iterator_breadth_first::add_state(const state* s)
{ {
todo.push_back(s); todo.emplace_back(s);
} }
const state* const state*
......
...@@ -104,7 +104,7 @@ namespace spot ...@@ -104,7 +104,7 @@ namespace spot
void exclusive_ap::add_group(std::vector<formula> ap) void exclusive_ap::add_group(std::vector<formula> ap)
{ {
groups.push_back(ap); groups.emplace_back(ap);
} }
namespace namespace
...@@ -130,12 +130,12 @@ namespace spot ...@@ -130,12 +130,12 @@ namespace spot
for (auto ap: g) for (auto ap: g)
if (s->find(ap) != s->end()) if (s->find(ap) != s->end())
group.push_back(ap); group.emplace_back(ap);
unsigned s = group.size(); unsigned s = group.size();
for (unsigned j = 0; j < s; ++j) for (unsigned j = 0; j < s; ++j)
for (unsigned k = j + 1; k < s; ++k) 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; delete s;
...@@ -166,7 +166,7 @@ namespace spot ...@@ -166,7 +166,7 @@ namespace spot
{ {
int v = d->has_registered_proposition(ap, aut); int v = d->has_registered_proposition(ap, aut);
if (v >= 0) if (v >= 0)
group.push_back(bdd_nithvar(v)); group.emplace_back(bdd_nithvar(v));
} }
unsigned s = group.size(); unsigned s = group.size();
......
...@@ -105,7 +105,7 @@ namespace spot ...@@ -105,7 +105,7 @@ namespace spot
{ {
if ((*i)->is_boolean()) if ((*i)->is_boolean())
{ {
b.push_back(*i); b.emplace_back(*i);
i = v.erase(i); i = v.erase(i);
} }
else else
...@@ -230,7 +230,7 @@ namespace spot ...@@ -230,7 +230,7 @@ namespace spot
{ {
unsigned ps = (*i)->size(); unsigned ps = (*i)->size();
for (unsigned n = 0; n < ps; ++n) for (unsigned n = 0; n < ps; ++n)
inlined.push_back((*i)->nth(n)->clone()); inlined.emplace_back((*i)->nth(n)->clone());
(*i)->destroy(); (*i)->destroy();
// FIXME: Do not use erase. See previous FIXME. // FIXME: Do not use erase. See previous FIXME.
i = v.erase(i); i = v.erase(i);
...@@ -242,7 +242,7 @@ namespace spot ...@@ -242,7 +242,7 @@ namespace spot
// For concat we have to keep track of the order of // For concat we have to keep track of the order of
// all the arguments. // all the arguments.
if (o == op::Concat || o == op::Fusion) if (o == op::Concat || o == op::Fusion)
inlined.push_back(*i); inlined.emplace_back(*i);
++i; ++i;
} }
if (o == op::Concat || o == op::Fusion) if (o == op::Concat || o == op::Fusion)
...@@ -470,10 +470,10 @@ namespace spot ...@@ -470,10 +470,10 @@ namespace spot
i->destroy(); i->destroy();
continue; continue;
} }
tmp.push_back(i); tmp.emplace_back(i);
} }
if (tmp.empty()) if (tmp.empty())
tmp.push_back(weak_abs); tmp.emplace_back(weak_abs);
v.swap(tmp); v.swap(tmp);
} }
} }
...@@ -1624,7 +1624,7 @@ namespace spot ...@@ -1624,7 +1624,7 @@ namespace spot
v.reserve(s - 1); v.reserve(s - 1);
for (unsigned j = 0; j < s; ++j) for (unsigned j = 0; j < s; ++j)
if (i != j) if (i != j)
v.push_back(nth(j)->clone()); v.emplace_back(nth(j)->clone());
return multop(o, v); return multop(o, v);
} }
default: default:
......
...@@ -1018,7 +1018,7 @@ namespace spot ...@@ -1018,7 +1018,7 @@ namespace spot
tmp.reserve(l.size()); tmp.reserve(l.size());
for (auto f: l) for (auto f: l)
if (f.ptr_) if (f.ptr_)
tmp.push_back(f.ptr_->clone()); tmp.emplace_back(f.ptr_->clone());
return formula(fnode::multop(o, std::move(tmp))); return formula(fnode::multop(o, std::move(tmp)));
} }
...@@ -1029,7 +1029,7 @@ namespace spot ...@@ -1029,7 +1029,7 @@ namespace spot
tmp.reserve(l.size()); tmp.reserve(l.size());
for (auto f: l) for (auto f: l)
if (f.ptr_) if (f.ptr_)
tmp.push_back(f.to_node_()); tmp.emplace_back(f.to_node_());
return formula(fnode::multop(o, std::move(tmp))); return formula(fnode::multop(o, std::move(tmp)));
} }
#endif // !SWIG #endif // !SWIG
...@@ -1628,7 +1628,7 @@ namespace spot ...@@ -1628,7 +1628,7 @@ namespace spot
std::vector<formula> tmp; std::vector<formula> tmp;
tmp.reserve(size()); tmp.reserve(size());
for (auto f: *this) for (auto f: *this)
tmp.push_back(trans(f)); tmp.emplace_back(trans(f));
return multop(o, std::move(tmp)); return multop(o, std::move(tmp));
} }
case op::Star: case op::Star:
......