aboutsummaryrefslogtreecommitdiffstats
path: root/libyul
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-08 19:24:21 +0800
committerGitHub <noreply@github.com>2018-11-08 19:24:21 +0800
commitb801e616118a06b4cc1f2e73a9ddecc5d585b827 (patch)
tree80a4a2ab469a5980e88a9d5345f9ad42285b517e /libyul
parentbf5b36a1ed8567b7b3bc27beb84d25ac9d0bf89c (diff)
parent845899e3052cd2ff26ead7d503f0e1edd8654d02 (diff)
downloaddexon-solidity-b801e616118a06b4cc1f2e73a9ddecc5d585b827.tar.gz
dexon-solidity-b801e616118a06b4cc1f2e73a9ddecc5d585b827.tar.zst
dexon-solidity-b801e616118a06b4cc1f2e73a9ddecc5d585b827.zip
Merge pull request #5365 from ethereum/improveNameDispenser
[Yul] Use single counter for name dispenser for performance reasons.
Diffstat (limited to 'libyul')
-rw-r--r--libyul/optimiser/NameDispenser.cpp5
-rw-r--r--libyul/optimiser/NameDispenser.h1
2 files changed, 3 insertions, 3 deletions
diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp
index 492c863d..3c870fa5 100644
--- a/libyul/optimiser/NameDispenser.cpp
+++ b/libyul/optimiser/NameDispenser.cpp
@@ -52,11 +52,10 @@ YulString NameDispenser::newName(YulString _nameHint, YulString _context)
YulString NameDispenser::newNameInternal(YulString _nameHint)
{
YulString name = _nameHint;
- size_t suffix = 0;
while (name.empty() || m_usedNames.count(name))
{
- suffix++;
- name = YulString(_nameHint.str() + "_" + to_string(suffix));
+ m_counter++;
+ name = YulString(_nameHint.str() + "_" + to_string(m_counter));
}
m_usedNames.emplace(name);
return name;
diff --git a/libyul/optimiser/NameDispenser.h b/libyul/optimiser/NameDispenser.h
index 57adbcad..7311440b 100644
--- a/libyul/optimiser/NameDispenser.h
+++ b/libyul/optimiser/NameDispenser.h
@@ -54,6 +54,7 @@ private:
YulString newNameInternal(YulString _nameHint);
std::set<YulString> m_usedNames;
+ size_t m_counter = 0;
};
}