[vala/emit-let: 2/2] codegen: Drop unnecessary comma expressions when boxing values



commit e647bf92e09a9781fd566ddbe4f84b5a9794aeb5
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Feb 15 16:44:55 2011 +0100

    codegen: Drop unnecessary comma expressions when boxing values
    
    Use one more temporary variable to avoid side-effects.

 codegen/valaccodebasemodule.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c006617..fe45bcf 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5385,11 +5385,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			} else {
 				var decl = get_temp_variable (expression_type, expression_type.value_owned, expression_type, false);
 				emit_temp_var (decl);
+				var result = get_temp_variable (target_type, target_type.value_owned, target_type, false);
+				emit_temp_var (result);
 
-				var ccomma = new CCodeCommaExpression ();
-				ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (decl.name), cexpr));
-				ccomma.append_expression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (decl.name)));
-				cexpr = ccomma;
+				ccode.add_assignment (get_variable_cexpression (decl.name), cexpr);
+				ccode.add_assignment (get_variable_cexpression (result.name), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (decl.name)));
+				cexpr = get_variable_cexpression (result.name);
 			}
 		} else if (unboxing) {
 			// unbox value



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