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



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 ?



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