From 3b241843a77ed29d10355fc17383da18d979bc5b Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 9 May 2018 01:45:50 +0200 Subject: Use NameDispenser in Disambiguator --- libjulia/optimiser/Disambiguator.cpp | 12 +----------- libjulia/optimiser/Disambiguator.h | 3 ++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/libjulia/optimiser/Disambiguator.cpp b/libjulia/optimiser/Disambiguator.cpp index df2984e5..b988dba7 100644 --- a/libjulia/optimiser/Disambiguator.cpp +++ b/libjulia/optimiser/Disambiguator.cpp @@ -38,17 +38,7 @@ string Disambiguator::translateIdentifier(string const& _originalName) Scope::Identifier const* id = m_scopes.back()->lookup(_originalName); solAssert(id, ""); if (!m_translations.count(id)) - { - string translated = _originalName; - size_t suffix = 0; - while (m_usedNames.count(translated)) - { - suffix++; - translated = _originalName + "_" + std::to_string(suffix); - } - m_usedNames.insert(translated); - m_translations[id] = translated; - } + m_translations[id] = m_nameDispenser.newName(_originalName); return m_translations.at(id); } diff --git a/libjulia/optimiser/Disambiguator.h b/libjulia/optimiser/Disambiguator.h index 18ffd157..6fc8a615 100644 --- a/libjulia/optimiser/Disambiguator.h +++ b/libjulia/optimiser/Disambiguator.h @@ -23,6 +23,7 @@ #include #include +#include #include @@ -60,7 +61,7 @@ protected: std::vector m_scopes; std::map m_translations; - std::set m_usedNames; + NameDispenser m_nameDispenser; }; } -- cgit v1.2.3