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



commit 4c5f3846afbc014caec468879a622f2be990a88a
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 c09ccba..7ef7710 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 c40811a..fac73ee 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5411,14 +5411,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]