From 027c075fb0e0609187d577c8d8a0138531845ec0 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 9 Jun 2025 18:01:12 -0700 Subject: [PATCH] gen-zam: Use const references instead of copying type values --- tools/gen-zam/src/Gen-ZAM.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/gen-zam/src/Gen-ZAM.cc b/tools/gen-zam/src/Gen-ZAM.cc index 5c1842ae5e..f17363e49f 100644 --- a/tools/gen-zam/src/Gen-ZAM.cc +++ b/tools/gen-zam/src/Gen-ZAM.cc @@ -1996,7 +1996,7 @@ void ZAM_UnaryExprOpTemplate::BuildInstruction(const OCVec& oc, { type_src = constant_op ? "n" : "n1"; Emit("auto " + type_src + " = flhs->GetOp1()->AsNameExpr();"); - Emit("auto t = flhs->GetType();"); + Emit("const auto& t = flhs->GetType();"); } else @@ -2005,7 +2005,7 @@ void ZAM_UnaryExprOpTemplate::BuildInstruction(const OCVec& oc, type_src = constant_op ? "n" : "n1"; auto type_suffix = zc == ZIC_VEC ? "->Yield();" : ";"; - Emit("auto t = " + type_src + "->GetType()" + type_suffix); + Emit("const auto& t = " + type_src + "->GetType()" + type_suffix); } BuildInstructionCore(params, suffix, zc); @@ -2127,7 +2127,7 @@ void ZAM_BinaryExprOpTemplate::BuildInstruction(const OCVec& oc, auto constant_op = oc[1] == ZAM_OC_CONSTANT; string type_src = constant_op ? "c" : "n2"; auto type_suffix = zc == ZIC_VEC ? "->Yield();" : ";"; - Emit("auto t = " + type_src + "->GetType()" + type_suffix); + Emit("const auto& t = " + type_src + "->GetType()" + type_suffix); GenerateSecondTypeVars(oc, zc); BuildInstructionCore(params, suffix, zc); @@ -2163,7 +2163,7 @@ void ZAM_BinaryExprOpTemplate::GenerateSecondTypeVars(const OCVec& oc, type_src2 = "n3"; } - Emit("auto t2 = " + type_src2 + "->GetType()" + type_suffix); + Emit("const auto& t2 = " + type_src2 + "->GetType()" + type_suffix); Emit("auto tag2 = t2->Tag();"); Emit("auto i_t2 = t2->InternalType();"); } @@ -2210,7 +2210,7 @@ void ZAM_RelationalExprOpTemplate::BuildInstruction(const OCVec& oc, } auto type_suffix = zc == ZIC_VEC ? "->Yield();" : ";"; - Emit("auto t = " + op1 + "->GetType()" + type_suffix); + Emit("const auto& t = " + op1 + "->GetType()" + type_suffix); GenerateSecondTypeVars(oc, zc); BuildInstructionCore(params, suffix, zc);