[vala] codegen: Drop useless temp variable when creating structs



commit 2a526194a2117988effd2f798f9447fbd5981c18
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Aug 26 09:34:15 2011 +0200

    codegen: Drop useless temp variable when creating structs
    
    Partially fixes 657378.

 codegen/valaccodebasemodule.vala |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4685ec2..0017ea2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;



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