[vala/wip/effectfree: 24/43] codegen: Drop useless temporary variables when storing a property



commit 7b0759b77745653f34e347d7ddda6a56a6905e7a
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Jun 18 09:53:15 2011 +0200

    codegen: Drop useless temporary variables when storing a property

 codegen/valaccodeassignmentmodule.vala |   21 ++-------------------
 codegen/valaccodebasemodule.vala       |    9 +--------
 2 files changed, 3 insertions(+), 27 deletions(-)
---
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index a3e8b2d..e2bc0ce 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -85,25 +85,8 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 			var ma = assignment.left as MemberAccess;
 			var prop = (Property) assignment.left.symbol_reference;
 
-			if (assignment.parent_node is ExpressionStatement) {
-				store_property (prop, ma.inner, assignment.right.target_value);
-
-				set_cvalue (assignment, get_ccodenode (assignment.right));
-			} else {
-				// when load_variable is changed to use temporary
-				// variables, this exception is no longer necessary
-
-				var temp_decl = get_temp_variable (prop.property_type);
-				emit_temp_var (temp_decl);
-				ccode.add_assignment (get_variable_cexpression (temp_decl.name), get_cvalue_ (assignment.right.target_value));
-
-				var target_value = ((GLibValue) assignment.right.target_value).copy ();
-				target_value.cvalue = get_variable_cexpression (temp_decl.name);
-
-				store_property (prop, ma.inner, target_value);
-
-				assignment.target_value = target_value;
-			}
+			store_property (prop, ma.inner, assignment.right.target_value);
+			assignment.target_value = assignment.right.target_value;
 		} else {
 			assignment.target_value = emit_simple_assignment (assignment);
 		}
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b275516..73cac61 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5421,14 +5421,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 		var array_type = prop.property_type as ArrayType;
 
-		if (array_type != null && !prop.no_array_length) {
-			var temp_var = get_temp_variable (prop.property_type, true, null, false);
-			emit_temp_var (temp_var);
-			ccode.add_assignment (get_variable_cexpression (temp_var.name), cexpr);
-			ccall.add_argument (get_variable_cexpression (temp_var.name));
-		} else {
-			ccall.add_argument (cexpr);
-		}
+		ccall.add_argument (cexpr);
 
 		if (array_type != null && !prop.no_array_length) {
 			for (int dim = 1; dim <= array_type.rank; dim++) {



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