[vala] codegen: Drop unnecessary temp variable when methods return a struct
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Drop unnecessary temp variable when methods return a struct
- Date: Fri, 26 Aug 2011 20:49:32 +0000 (UTC)
commit 2643d03b3a0f95202049a1f2f87327d69073e15d
Author: Luca Bruno <lucabru src gnome org>
Date: Fri Aug 26 22:44:27 2011 +0200
codegen: Drop unnecessary temp variable when methods return a struct
codegen/valaccodemethodcallmodule.vala | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 7d92d72..d9ae9a6 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -747,13 +747,18 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
}
- var temp_var = get_temp_variable (result_type, result_type.value_owned);
- var temp_ref = get_variable_cexpression (temp_var.name);
+ if (!return_result_via_out_param) {
+ var temp_var = get_temp_variable (result_type, result_type.value_owned);
+ var temp_ref = get_variable_cexpression (temp_var.name);
- emit_temp_var (temp_var);
+ emit_temp_var (temp_var);
- ccode.add_assignment (temp_ref, ccall_expr);
- set_cvalue (expr, temp_ref);
+ ccode.add_assignment (temp_ref, ccall_expr);
+ set_cvalue (expr, temp_ref);
+ } else {
+ set_cvalue (expr, ccall_expr);
+ }
+ ((GLibValue) expr.target_value).lvalue = true;
}
params_it = params.iterator ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]