diff options
author | chriseth <chris@ethereum.org> | 2018-11-08 02:27:15 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-08 06:09:33 +0800 |
commit | 845899e3052cd2ff26ead7d503f0e1edd8654d02 (patch) | |
tree | b1683eefae794dc7337b3d8943125b4fdc22e777 /libyul/optimiser | |
parent | deed8e21f6149a9712ebd77556cdb6e3b4b9c566 (diff) | |
download | dexon-solidity-845899e3052cd2ff26ead7d503f0e1edd8654d02.tar.gz dexon-solidity-845899e3052cd2ff26ead7d503f0e1edd8654d02.tar.zst dexon-solidity-845899e3052cd2ff26ead7d503f0e1edd8654d02.zip |
Use single counter for name dispenser for performance reasons.
Diffstat (limited to 'libyul/optimiser')
-rw-r--r-- | libyul/optimiser/NameDispenser.cpp | 5 | ||||
-rw-r--r-- | libyul/optimiser/NameDispenser.h | 1 |
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; }; } |