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
|
|
@ -102,13 +102,13 @@ namespace spot
|
|||
atomic_prop::instance(const std::string& name, environment& env)
|
||||
{
|
||||
pair p(name, &env);
|
||||
// FIXME: Use lower_bound, or a hash_map.
|
||||
map::iterator i = instances.find(p);
|
||||
const atomic_prop* ap;
|
||||
if (i != instances.end())
|
||||
ap = i->second;
|
||||
std::pair<map::iterator, bool> ires =
|
||||
instances.insert(map::value_type(p, 0));
|
||||
if (!ires.second)
|
||||
ap = ires.first->second;
|
||||
else
|
||||
ap = instances[p] = new atomic_prop(name, env);
|
||||
ap = ires.first->second = new atomic_prop(name, env);
|
||||
ap->clone();
|
||||
return ap;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue