[vala/staging: 5/6] codegen: Avoid use of temp-var for some callables returning ValueType
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 5/6] codegen: Avoid use of temp-var for some callables returning ValueType
- Date: Wed, 22 Nov 2017 20:52:17 +0000 (UTC)
commit a94a28141e1f222d1da7e72bea4cd2d1e5242f41
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Mar 9 16:52:37 2017 +0100
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
codegen/valaccodemethodcallmodule.vala | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index cf2a3f5..82a0574 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -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;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]