Merge pull request #4094 from ethereum/disambiguator-cleanup

Use NameDispenser in Disambiguator
This commit is contained in:
chriseth 2018-05-09 10:55:52 +02:00 committed by GitHub
commit 58c63dcc9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 12 deletions

View File

@ -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);
}

View File

@ -23,6 +23,7 @@
#include <libjulia/ASTDataForward.h>
#include <libjulia/optimiser/ASTCopier.h>
#include <libjulia/optimiser/NameDispenser.h>
#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
@ -60,7 +61,7 @@ protected:
std::vector<solidity::assembly::Scope*> m_scopes;
std::map<void const*, std::string> m_translations;
std::set<std::string> m_usedNames;
NameDispenser m_nameDispenser;
};
}