Use curly-brackets initialization

This commit is contained in:
Mathias Baumann 2018-12-10 19:03:47 +01:00
parent 2f6dc2e773
commit cb935fe908
2 changed files with 14 additions and 14 deletions

View File

@ -353,14 +353,14 @@ AssemblyItem Assembly::namedTag(string const& _name)
assertThrow(!_name.empty(), AssemblyException, "Empty named tag."); assertThrow(!_name.empty(), AssemblyException, "Empty named tag.");
if (!m_namedTags.count(_name)) if (!m_namedTags.count(_name))
m_namedTags[_name] = size_t(newTag().data()); m_namedTags[_name] = size_t(newTag().data());
return AssemblyItem(Tag, m_namedTags.at(_name)); return AssemblyItem{Tag, m_namedTags.at(_name)};
} }
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier) AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
{ {
h256 h(dev::keccak256(_identifier)); h256 h(dev::keccak256(_identifier));
m_libraries[h] = _identifier; m_libraries[h] = _identifier;
return AssemblyItem(PushLibraryAddress, h); return AssemblyItem{PushLibraryAddress, h};
} }
Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs) Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs)
@ -415,14 +415,14 @@ map<u256, u256> Assembly::optimiseInternal(
if (_settings.runJumpdestRemover) if (_settings.runJumpdestRemover)
{ {
JumpdestRemover jumpdestOpt(m_items); JumpdestRemover jumpdestOpt{m_items};
if (jumpdestOpt.optimise(_tagsReferencedFromOutside)) if (jumpdestOpt.optimise(_tagsReferencedFromOutside))
count++; count++;
} }
if (_settings.runPeephole) if (_settings.runPeephole)
{ {
PeepholeOptimiser peepOpt(m_items); PeepholeOptimiser peepOpt{m_items};
while (peepOpt.optimise()) while (peepOpt.optimise())
{ {
count++; count++;
@ -433,7 +433,7 @@ map<u256, u256> Assembly::optimiseInternal(
// This only modifies PushTags, we have to run again to actually remove code. // This only modifies PushTags, we have to run again to actually remove code.
if (_settings.runDeduplicate) if (_settings.runDeduplicate)
{ {
BlockDeduplicator dedup(m_items); BlockDeduplicator dedup{m_items};
if (dedup.deduplicate()) if (dedup.deduplicate())
{ {
tagReplacements.insert(dedup.replacedTags().begin(), dedup.replacedTags().end()); tagReplacements.insert(dedup.replacedTags().begin(), dedup.replacedTags().end());
@ -448,13 +448,13 @@ map<u256, u256> Assembly::optimiseInternal(
// function types that can be stored in storage. // function types that can be stored in storage.
AssemblyItems optimisedItems; AssemblyItems optimisedItems;
bool usesMSize = (find(m_items.begin(), m_items.end(), AssemblyItem(Instruction::MSIZE)) != m_items.end()); bool usesMSize = (find(m_items.begin(), m_items.end(), AssemblyItem{Instruction::MSIZE}) != m_items.end());
auto iter = m_items.begin(); auto iter = m_items.begin();
while (iter != m_items.end()) while (iter != m_items.end())
{ {
KnownState emptyState; KnownState emptyState;
CommonSubexpressionEliminator eliminator(emptyState); CommonSubexpressionEliminator eliminator{emptyState};
auto orig = iter; auto orig = iter;
iter = eliminator.feedItems(iter, m_items.end(), usesMSize); iter = eliminator.feedItems(iter, m_items.end(), usesMSize);
bool shouldReplace = false; bool shouldReplace = false;

View File

@ -41,7 +41,7 @@ bool BlockDeduplicator::deduplicate()
// Virtual tag that signifies "the current block" and which is used to optimise loops. // Virtual tag that signifies "the current block" and which is used to optimise loops.
// We abort if this virtual tag actually exists. // We abort if this virtual tag actually exists.
AssemblyItem pushSelf(PushTag, u256(-4)); AssemblyItem pushSelf{PushTag, u256(-4)};
if ( if (
std::count(m_items.cbegin(), m_items.cend(), pushSelf.tag()) || std::count(m_items.cbegin(), m_items.cend(), pushSelf.tag()) ||
std::count(m_items.cbegin(), m_items.cend(), pushSelf.pushTag()) std::count(m_items.cbegin(), m_items.cend(), pushSelf.pushTag())
@ -55,17 +55,17 @@ bool BlockDeduplicator::deduplicate()
// To compare recursive loops, we have to already unify PushTag opcodes of the // To compare recursive loops, we have to already unify PushTag opcodes of the
// block's own tag. // block's own tag.
AssemblyItem pushFirstTag(pushSelf); AssemblyItem pushFirstTag{pushSelf};
AssemblyItem pushSecondTag(pushSelf); AssemblyItem pushSecondTag{pushSelf};
if (_i < m_items.size() && m_items.at(_i).type() == Tag) if (_i < m_items.size() && m_items.at(_i).type() == Tag)
pushFirstTag = m_items.at(_i).pushTag(); pushFirstTag = m_items.at(_i).pushTag();
if (_j < m_items.size() && m_items.at(_j).type() == Tag) if (_j < m_items.size() && m_items.at(_j).type() == Tag)
pushSecondTag = m_items.at(_j).pushTag(); pushSecondTag = m_items.at(_j).pushTag();
BlockIterator first(m_items.begin() + _i, m_items.end(), &pushFirstTag, &pushSelf); BlockIterator first{m_items.begin() + _i, m_items.end(), &pushFirstTag, &pushSelf};
BlockIterator second(m_items.begin() + _j, m_items.end(), &pushSecondTag, &pushSelf); BlockIterator second{m_items.begin() + _j, m_items.end(), &pushSecondTag, &pushSelf};
BlockIterator end(m_items.end(), m_items.end()); BlockIterator end{m_items.end(), m_items.end()};
if (first != end && (*first).type() == Tag) if (first != end && (*first).type() == Tag)
++first; ++first;
@ -126,7 +126,7 @@ BlockDeduplicator::BlockIterator& BlockDeduplicator::BlockIterator::operator++()
{ {
if (it == end) if (it == end)
return *this; return *this;
if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem(Instruction::JUMPI)) if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem{Instruction::JUMPI})
it = end; it = end;
else else
{ {