Skip to content

Commit 7951872

Browse files
committed
Removed unnecesary nested_lets variable, use writer.print instead
1 parent bebdd88 commit 7951872

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

backends/functional/smtlib.cc

+9-12
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ struct SmtModule {
231231
auto node_to_string = [&](FunctionalIR::Node n) { return scope[n.name()]; };
232232
SmtPrintVisitor<decltype(node_to_string)> visitor(node_to_string, scope);
233233

234-
std::string nested_lets;
235234
for (auto it = ir.begin(); it != ir.end(); ++it) {
236235
const FunctionalIR::Node &node = *it;
237236

@@ -241,31 +240,29 @@ struct SmtModule {
241240
std::string node_name = replaceCharacters(scope[node.name()]);
242241
std::string node_expr = node.visit(visitor);
243242

244-
nested_lets += "(let ( (" + node_name + " " + node_expr + "))";
243+
writer.print(" (let ( (%s %s))", node_name.c_str(), node_expr.c_str());
245244
}
246245

247-
nested_lets += " (let (";
246+
writer.print(" (let (");
248247
for (const auto &output : ir.outputs()) {
249248
std::string output_name = scope[output.first];
250249
const std::string output_assignment = ir.get_output_node(output.first).name().c_str();
251-
nested_lets += " (" + output_name + " " + replaceCharacters(output_assignment).substr(1) + ")";
250+
writer.print(" (%s %s)", output_name.c_str(), replaceCharacters(output_assignment).substr(1).c_str());
252251
}
253-
nested_lets += " )";
254-
nested_lets += " (mk_outputs";
255-
252+
writer.print(" )");
253+
writer.print(" (mk_outputs");
256254
for (const auto &output : ir.outputs()) {
257255
std::string output_name = scope[output.first];
258-
nested_lets += " " + output_name;
256+
writer.print(" %s", output_name.c_str());
259257
}
260-
nested_lets += " )";
261-
nested_lets += " )";
258+
writer.print(" )");
259+
writer.print(" )");
262260

263261
// Close the nested lets
264262
for (size_t i = 0; i < ir.size() - ir.inputs().size(); ++i) {
265-
nested_lets += " )";
263+
writer.print(" )");
266264
}
267265

268-
writer.print("%s", nested_lets.c_str());
269266
writer.print(" )");
270267
writer.print(")\n");
271268
}

0 commit comments

Comments
 (0)