ltlast: simplify with std::make_pair() and c++11's std::tuple
* src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh, src/ltlast/automatop.cc, src/ltlast/automatop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/bunop.cc, src/ltlast/bunop.hh, src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/unop.cc, src/ltlast/unop.hh: Use std::tuple to replace nested std::pair, simplify calls to std::map::erase, use auto and std::make_pair with insert, and simplify the dump() method using a range for.
This commit is contained in:
parent
c64503fb33
commit
b37dc0bc90
12 changed files with 89 additions and 119 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include "binop.hh"
|
||||
#include "unop.hh"
|
||||
|
|
@ -250,11 +251,9 @@ namespace spot
|
|||
binop::~binop()
|
||||
{
|
||||
// Get this instance out of the instance map.
|
||||
pairf pf(first(), second());
|
||||
pair p(op(), pf);
|
||||
map::iterator i = instances.find(p);
|
||||
assert (i != instances.end());
|
||||
instances.erase(i);
|
||||
size_t c = instances.erase(key(op(), first(), second()));
|
||||
assert(c == 1);
|
||||
(void) c; // For the NDEBUG case.
|
||||
|
||||
// Dereference children.
|
||||
first()->destroy();
|
||||
|
|
@ -506,12 +505,9 @@ namespace spot
|
|||
break;
|
||||
}
|
||||
|
||||
pairf pf(first, second);
|
||||
pair p(op, pf);
|
||||
|
||||
const binop* res;
|
||||
std::pair<map::iterator, bool> ires =
|
||||
instances.insert(map::value_type(p, 0));
|
||||
auto ires = instances.insert(std::make_pair(key(op, first, second),
|
||||
nullptr));
|
||||
if (!ires.second)
|
||||
{
|
||||
// This instance already exists.
|
||||
|
|
@ -536,15 +532,12 @@ namespace spot
|
|||
std::ostream&
|
||||
binop::dump_instances(std::ostream& os)
|
||||
{
|
||||
for (map::iterator i = instances.begin(); i != instances.end(); ++i)
|
||||
{
|
||||
os << i->second << " = "
|
||||
<< i->second->ref_count_() << " * "
|
||||
<< i->second->dump()
|
||||
<< std::endl;
|
||||
}
|
||||
for (const auto& i: instances)
|
||||
os << i.second << " = "
|
||||
<< i.second->ref_count_() << " * "
|
||||
<< i.second->dump()
|
||||
<< std::endl;
|
||||
return os;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue