Commit a94a2814 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Avoid use of temp-var for some callables returning ValueType

It is safe to do for callables which don't have out/ref parameters without
breaking the control-flow.

https://bugzilla.gnome.org/show_bug.cgi?id=789071
parent b9035aaf
......@@ -805,6 +805,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
set_cvalue (expr, ccall_expr);
} else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) {
set_cvalue (expr, ccall_expr);
} else if (!return_result_via_out_param
&& ((m != null && !has_ref_out_param (m)) || (deleg != null && !has_ref_out_param (deleg)))
&& (result_type is ValueType && !result_type.is_disposable ())) {
set_cvalue (expr, ccall_expr);
} else if (!return_result_via_out_param) {
var temp_var = get_temp_variable (result_type, result_type.value_owned, null, false);
var temp_ref = get_variable_cexpression (temp_var.name);
......@@ -896,5 +900,14 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
return to_string_func;
}
bool has_ref_out_param (Callable c) {
foreach (var param in c.get_parameters ()) {
if (param.direction != ParameterDirection.IN) {
return true;
}
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment