Commit c830b5db authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

* spot/tl/formula.cc: Fix two fixmes.

parent dc34862d
...@@ -254,46 +254,35 @@ namespace spot ...@@ -254,46 +254,35 @@ namespace spot
// //
// When we construct a formula such as Multop(Op,X,Multop(Op,Y,Z)) // When we construct a formula such as Multop(Op,X,Multop(Op,Y,Z))
// we will want to inline it as Multop(Op,X,Y,Z). // we will want to inline it as Multop(Op,X,Y,Z).
{ //
vec inlined; // At the same time, it's possible that vec contains some null
vec::iterator i = v.begin(); // pointers we should remove. We can do it in the same loop.
while (i != v.end()) //
{ // It is simpler to construct a separate vector to do that, but that's
// Some simplification routines erase terms using null // only needed if we have nested multops or null poiners.
// pointers that we must ignore. if (std::find_if(v.begin(), v.end(),
if ((*i) == nullptr) [o](const fnode* f) { return f == nullptr || f->is(o); })
{ != v.end())
// FIXME: For commutative operators we should replace {
// the pointer by the first non-null value at the end vec inlined;
// of the array instead of calling erase. for (const fnode* f: v)
i = v.erase(i); {
continue; if (f == nullptr)
}
if ((*i)->is(o))
{
unsigned ps = (*i)->size();
for (unsigned n = 0; n < ps; ++n)
inlined.emplace_back((*i)->nth(n)->clone());
(*i)->destroy();
// FIXME: Do not use erase. See previous FIXME.
i = v.erase(i);
continue; continue;
} if (f->is(o))
// All operators except "Concat" and "Fusion" are {
// commutative, so we just keep a list of the inlined unsigned ps = f->size();
// arguments that should later be added to the vector. for (unsigned n = 0; n < ps; ++n)
// For concat we have to keep track of the order of inlined.emplace_back(f->nth(n)->clone());
// all the arguments. f->destroy();
if (o == op::Concat || o == op::Fusion) }
inlined.emplace_back(*i); else
++i; {
} inlined.emplace_back(f);
if (o == op::Concat || o == op::Fusion) }
}
v.swap(inlined); v.swap(inlined);
else }
v.insert(v.end(), inlined.begin(), inlined.end());
}
if (o != op::Concat && o != op::Fusion) if (o != op::Concat && o != op::Fusion)
std::sort(v.begin(), v.end(), formula_ptr_less_than_bool_first()); std::sort(v.begin(), v.end(), formula_ptr_less_than_bool_first());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment