From ee6bd5943684f49d933f233ddc1dbe464521921c Mon Sep 17 00:00:00 2001
From: Roland Coeurjoly <rolandcoeurjoly@gmail.com>
Date: Thu, 27 Jun 2024 04:14:05 +0200
Subject: [PATCH] Removed unnecesary nested_lets variable, use writer.print
 instead

---
 backends/functional/smtlib.cc | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/backends/functional/smtlib.cc b/backends/functional/smtlib.cc
index 49dd5cf0d..7f1ca0a61 100644
--- a/backends/functional/smtlib.cc
+++ b/backends/functional/smtlib.cc
@@ -231,7 +231,6 @@ struct SmtModule {
 		auto node_to_string = [&](FunctionalIR::Node n) { return scope[n.name()]; };
 		SmtPrintVisitor<decltype(node_to_string)> visitor(node_to_string, scope);
 
-		std::string nested_lets;
 		for (auto it = ir.begin(); it != ir.end(); ++it) {
 			const FunctionalIR::Node &node = *it;
 
@@ -241,31 +240,29 @@ struct SmtModule {
 			std::string node_name = replaceCharacters(scope[node.name()]);
 			std::string node_expr = node.visit(visitor);
 
-			nested_lets += "(let (      (" + node_name + " " + node_expr + "))";
+			writer.print("  (let (      (%s %s))", node_name.c_str(), node_expr.c_str());
 		}
 
-		nested_lets += "          (let (";
+		writer.print("    (let (");
 		for (const auto &output : ir.outputs()) {
 			std::string output_name = scope[output.first];
 			const std::string output_assignment = ir.get_output_node(output.first).name().c_str();
-			nested_lets += "            (" + output_name + " " + replaceCharacters(output_assignment).substr(1) + ")";
+			writer.print("      (%s %s)", output_name.c_str(), replaceCharacters(output_assignment).substr(1).c_str());
 		}
-		nested_lets += "          )";
-		nested_lets += "            (mk_outputs";
-
+		writer.print("    )");
+		writer.print("      (mk_outputs");
 		for (const auto &output : ir.outputs()) {
 			std::string output_name = scope[output.first];
-			nested_lets += "              " + output_name;
+			writer.print("        %s", output_name.c_str());
 		}
-		nested_lets += "            )";
-		nested_lets += "          )";
+		writer.print("      )");
+		writer.print("    )");
 
 		// Close the nested lets
 		for (size_t i = 0; i < ir.size() - ir.inputs().size(); ++i) {
-			nested_lets += "    )";
+			writer.print("  )");
 		}
 
-		writer.print("%s", nested_lets.c_str());
 		writer.print("  )");
 		writer.print(")\n");
 	}