]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Avoid generating unused temporary variables with out arguments
authorJürg Billeter <j@bitron.ch>
Sun, 21 Mar 2010 09:29:25 +0000 (10:29 +0100)
committerJürg Billeter <j@bitron.ch>
Sun, 21 Mar 2010 09:29:25 +0000 (10:29 +0100)
codegen/valaccodemethodcallmodule.vala

index 267bf5c543ff30ef5d5766f39d686a644c713aa2..8439beca3a206be632606bf01eba964f3feba6a5 100644 (file)
@@ -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));
                                                }