ltlast: use the return of insert() to avoid a double lookup
* src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc, src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/multop.cc, src/ltlast/unop.cc: Do not look for a key and then insert the (key,value) on failure. Simply insert (key,0), and replace 0 by value on failure. This replaces two map lookups by one.
This commit is contained in:
parent
2776de87da
commit
13c41ee773
6 changed files with 41 additions and 30 deletions
|
|
@ -262,14 +262,20 @@ namespace spot
|
|||
}
|
||||
|
||||
pair p(pairo(op, child), pairu(min, max));
|
||||
map::iterator i = instances.find(p);
|
||||
if (i != instances.end())
|
||||
|
||||
const formula* res;
|
||||
std::pair<map::iterator, bool> ires =
|
||||
instances.insert(map::value_type(p, 0));
|
||||
if (!ires.second)
|
||||
{
|
||||
// This instance already exists.
|
||||
child->destroy();
|
||||
return i->second->clone();
|
||||
res = ires.first->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ires.first->second = new bunop(op, child, min, max);
|
||||
}
|
||||
const bunop* res = instances[p] = new bunop(op, child, min, max);
|
||||
res->clone();
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue