aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-09 16:55:52 +0800
committerGitHub <noreply@github.com>2018-05-09 16:55:52 +0800
commit58c63dcc9ce61b2742a10dc337cc5d0fd8739471 (patch)
tree64c1ca423862dcea7df7fdd9d3f7a8a15834395f
parent10792dbc909bdd2c8ba7c0301ed81ee28b0ae1cc (diff)
parent3b241843a77ed29d10355fc17383da18d979bc5b (diff)
downloaddexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar.gz
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar.bz2
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar.lz
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar.xz
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.tar.zst
dexon-solidity-58c63dcc9ce61b2742a10dc337cc5d0fd8739471.zip
Merge pull request #4094 from ethereum/disambiguator-cleanup
Use NameDispenser in Disambiguator
-rw-r--r--libjulia/optimiser/Disambiguator.cpp12
-rw-r--r--libjulia/optimiser/Disambiguator.h3
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 <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;
};
}