Skip to content

Commit 0f7876b

Browse files
committed
Minors.
1 parent 1c4145d commit 0f7876b

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

libevmasm/Assembly.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,14 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
109109
std::string name = getOrDefault<std::string>(_json, "name", "");
110110
solAssert(!name.empty());
111111

112-
int begin = get<int>(_json, "begin");
113-
int end = get<int>(_json, "end");
112+
SourceLocation location;
113+
location.start = get<int>(_json, "begin");
114+
location.end = get<int>(_json, "end");
114115
int srcIndex = get<int>(_json, "source");
115116
size_t modifierDepth = static_cast<size_t>(getOrDefault<int>(_json, "modifierDepth", 0));
116117
std::string value = getOrDefault<std::string>(_json, "value", "");
117118
std::string jumpType = getOrDefault<std::string>(_json, "jumpType", "");
118119

119-
SourceLocation location;
120-
location.start = begin;
121-
location.end = end;
122120

123121
auto updateUsedTags = [&](u256 const& data) {
124122
m_usedTags = max(m_usedTags, static_cast<unsigned>(data) + 1);
@@ -142,10 +140,9 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
142140

143141
AssemblyItem result(0);
144142

145-
if (c_instructions.find(name) != c_instructions.end())
143+
if (c_instructions.count(name))
146144
{
147145
AssemblyItem item{c_instructions.at(name), location};
148-
item.m_modifierDepth = modifierDepth;
149146
if (!jumpType.empty())
150147
item.setJumpType(jumpType);
151148
result = item;
@@ -154,42 +151,42 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json)
154151
{
155152
if (name == "PUSH")
156153
{
157-
AssemblyItem item{AssemblyItemType::Push, u256("0x" + value), location};
154+
AssemblyItem item{AssemblyItemType::Push, u256("0x" + value)};
158155
if (!jumpType.empty())
159156
item.setJumpType(jumpType);
160157
result = item;
161158
}
162159
else if (name == "PUSH [ErrorTag]")
163-
result = {AssemblyItemType::PushTag, 0, location};
160+
result = {AssemblyItemType::PushTag, 0};
164161
else if (name == "PUSH [tag]")
165-
result = {AssemblyItemType::PushTag, updateUsedTags(u256(value)), location};
162+
result = {AssemblyItemType::PushTag, updateUsedTags(u256(value))};
166163
else if (name == "PUSH [$]")
167-
result = {AssemblyItemType::PushSub, u256("0x" + value), location};
164+
result = {AssemblyItemType::PushSub, u256("0x" + value)};
168165
else if (name == "PUSH #[$]")
169-
result = {AssemblyItemType::PushSubSize, u256("0x" + value), location};
166+
result = {AssemblyItemType::PushSubSize, u256("0x" + value)};
170167
else if (name == "PUSHSIZE")
171-
result = {AssemblyItemType::PushProgramSize, 0, location};
168+
result = {AssemblyItemType::PushProgramSize, 0};
172169
else if (name == "PUSHLIB")
173-
result = {AssemblyItemType::PushLibraryAddress, libraryHash(value), location};
170+
result = {AssemblyItemType::PushLibraryAddress, libraryHash(value)};
174171
else if (name == "PUSHDEPLOYADDRESS")
175-
result = {AssemblyItemType::PushDeployTimeAddress, 0, location};
172+
result = {AssemblyItemType::PushDeployTimeAddress, 0};
176173
else if (name == "PUSHIMMUTABLE")
177-
result = {AssemblyItemType::PushImmutable, immutableHash(value), location};
174+
result = {AssemblyItemType::PushImmutable, immutableHash(value)};
178175
else if (name == "ASSIGNIMMUTABLE")
179-
result = {AssemblyItemType::AssignImmutable, immutableHash(value), location};
176+
result = {AssemblyItemType::AssignImmutable, immutableHash(value)};
180177
else if (name == "tag")
181-
result = {AssemblyItemType::Tag, updateUsedTags(u256(value)), location};
178+
result = {AssemblyItemType::Tag, updateUsedTags(u256(value))};
182179
else if (name == "PUSH data")
183-
result = {AssemblyItemType::PushData, u256("0x" + value), location};
180+
result = {AssemblyItemType::PushData, u256("0x" + value)};
184181
else if (name == "VERBATIM")
185182
{
186183
AssemblyItem item(fromHex(value), 0, 0);
187-
item.setLocation(location);
188184
result = item;
189185
}
190186
else
191187
assertThrow(false, InvalidOpcode, "");
192188
}
189+
result.setLocation(location);
193190
result.m_modifierDepth = modifierDepth;
194191
return result;
195192
}

libsolidity/interface/CompilerStack.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ void CompilerStack::setLibraries(std::map<std::string, util::h160> const& _libra
242242
void CompilerStack::setOptimiserSettings(bool _optimize, size_t _runs)
243243
{
244244
OptimiserSettings settings = _optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal();
245+
settings.enabled = _optimize;
245246
settings.expectedExecutionsPerDeployment = _runs;
246247
setOptimiserSettings(std::move(settings));
247248
}

solc/CommandLineParser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ OptimiserSettings CommandLineOptions::optimiserSettings() const
270270
if (optimizer.yulSteps.has_value())
271271
settings.yulOptimiserSteps = optimizer.yulSteps.value();
272272

273-
settings.enabled = optimizer.enabled;
274-
275273
return settings;
276274
}
277275

0 commit comments

Comments
 (0)