Re: [Vala] Why the temporary variables in the C code are usefull ?

The compiler can optimize this. Those temp vars are just to make the vala compiler simpler.. It would be 
great if vala could do some minor optimization steps before spitting C. But if you compile with -O2 it 
shouldnt be something to worry.

On 06/07/2011, at 18:51, Jacques-Pascal Deplaix <jp deplaix gmail com> wrote:

Hi everybody,

Why assignements in Vala make C code with multiples temporary variables ?
It's not very good for the performances...
I read codegen/valaccodeassignmentmodule.vala and I found this:

if (!is_pure_ccode_expression (lhs)) {
   /* Assign lhs to temp var to avoid repeating side effect */
   var lhs_value_type = assignment.left.value_type.copy ();
   string lhs_temp_name = "_tmp%d_".printf (next_temp_var_id++);
   var lhs_temp = new LocalVariable (lhs_value_type, "*" + lhs_temp_name);
   emit_temp_var (lhs_temp);
   ccode.add_assignment (get_variable_cexpression (lhs_temp_name), new CCodeUnaryExpression 
(CCodeUnaryOperator.ADDRESS_OF, lhs));
    lhs = new CCodeParenthesizedExpression (new CCodeUnaryExpression 
(CCodeUnaryOperator.POINTER_INDIRECTION, get_variable_cexpression (lhs_temp_name)));

What are the side effects corrected by the temporary variables ?
vala-list mailing list
vala-list gnome org

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