From c7b3148cb4b967fa242002f16ee78cec8caee70c Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 23 Jan 2014 14:23:35 +0100 Subject: [PATCH] * src/tgbaalgos/degen.cc (unicity_table): Simplify. --- src/tgbaalgos/degen.cc | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/tgbaalgos/degen.cc b/src/tgbaalgos/degen.cc index 5703145c3..47bab85f3 100644 --- a/src/tgbaalgos/degen.cc +++ b/src/tgbaalgos/degen.cc @@ -1,5 +1,6 @@ -// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement -// de l'Epita. +// -*- coding: utf-8 -*- +// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et +// Développement de l'Epita. // // This file is part of Spot, a model checking library. // @@ -69,32 +70,23 @@ namespace spot // Memory management for the input states. class unicity_table { - typedef std::unordered_set uniq_set; - uniq_set m; + state_set m; public: const state* operator()(const state* s) { - uniq_set::const_iterator i = m.find(s); - if (i == m.end()) - { - m.insert(s); - return s; - } - else - { - s->destroy(); - return *i; - } + auto p = m.insert(s); + if (!p.second) + s->destroy(); + return *p.first; } ~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 // avoid issues with old g++ implementations. - uniq_set::iterator old = i++; + state_set::iterator old = i++; (*old)->destroy(); } }