[vala] Avoid generating unused temporary variables with out arguments



commit 223de7f3e307d34a0d3e589bdf2e808a1afd0e14
Author: Jürg Billeter <j bitron ch>
Date:   Sun Mar 21 10:29:25 2010 +0100

    Avoid generating unused temporary variables with out arguments

 codegen/valaccodemethodcallmodule.vala |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 267bf5c..8439bec 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -427,7 +427,8 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
 						// call function
 						LocalVariable ret_temp_var = null;
-						if (itype.get_return_type () is VoidType || itype.get_return_type ().is_real_struct_type ()) {
+						if (itype.get_return_type () is VoidType || itype.get_return_type ().is_real_struct_type () ||
+						    (expr.parent_node is ExpressionStatement && !requires_destroy (itype.get_return_type ()))) {
 							ccomma.append_expression (ccall_expr);
 						} else {
 							ret_temp_var = get_temp_variable (itype.get_return_type (), true, null, false);
@@ -451,7 +452,7 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 						ccomma.append_expression (new CCodeAssignment ((CCodeExpression) unary.inner.ccodenode, cassign_comma));
 
 						// return value
-						if (!(itype.get_return_type () is VoidType || itype.get_return_type ().is_real_struct_type ())) {
+						if (ret_temp_var != null) {
 							ccomma.append_expression (get_variable_cexpression (ret_temp_var.name));
 						}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]