* src/tgbaalgos/degen.cc (unicity_table): Simplify.

This commit is contained in:
Alexandre Duret-Lutz 2014-01-23 14:23:35 +01:00
parent bd6d88db96
commit c7b3148cb4

View file

@ -1,5 +1,6 @@
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement // -*- coding: utf-8 -*-
// de l'Epita. // Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita.
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -69,32 +70,23 @@ namespace spot
// Memory management for the input states. // Memory management for the input states.
class unicity_table class unicity_table
{ {
typedef std::unordered_set<const state*, state_set m;
state_ptr_hash, state_ptr_equal> uniq_set;
uniq_set m;
public: public:
const state* operator()(const state* s) const state* operator()(const state* s)
{ {
uniq_set::const_iterator i = m.find(s); auto p = m.insert(s);
if (i == m.end()) if (!p.second)
{
m.insert(s);
return s;
}
else
{
s->destroy(); s->destroy();
return *i; return *p.first;
}
} }
~unicity_table() ~unicity_table()
{ {
for (uniq_set::iterator i = m.begin(); i != m.end();) for (state_set::iterator i = m.begin(); i != m.end();)
{ {
// Advance the iterator before destroying its key. This // Advance the iterator before destroying its key. This
// avoid issues with old g++ implementations. // avoid issues with old g++ implementations.
uniq_set::iterator old = i++; state_set::iterator old = i++;
(*old)->destroy(); (*old)->destroy();
} }
} }