]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Drop useless temp variable when creating structs
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 26 Aug 2011 07:34:15 +0000 (09:34 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 26 Aug 2011 08:33:41 +0000 (10:33 +0200)
Partially fixes 657378.

codegen/valaccodebasemodule.vala

index 4685ec2e38de1d5d61f0174610dead65e9151081..0017ea29551eeed337aece8af86ebc8e0e44eeee 100644 (file)
@@ -4336,7 +4336,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        // no temporary variable necessary
                        ccode.add_expression (creation_expr);
                        set_cvalue (expr, instance);
-                       return;
                } else if (instance != null) {
                        if (expr.type_reference.data_type is Struct) {
                                ccode.add_expression (creation_expr);
@@ -4363,10 +4362,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                }
                        }
 
-                       creation_expr = instance;
-               }
-
-               if (creation_expr != null) {
+                       set_cvalue (expr, instance);
+               } else if (creation_expr != null) {
                        var temp_value = create_temp_value (expr.value_type, false, expr);
                        ccode.add_assignment (get_cvalue_ (temp_value), creation_expr);
                        expr.target_value = temp_value;