[vala] codegen: Drop extra copy of captured unowned parameters in async methods
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Drop extra copy of captured unowned parameters in async methods
- Date: Wed, 15 Aug 2012 10:31:15 +0000 (UTC)
commit 2499aa65087cb86c3194afb183bc82d687e0bb20
Author: JÃrg Billeter <j bitron ch>
Date: Wed Aug 15 10:45:33 2012 +0200
codegen: Drop extra copy of captured unowned parameters in async methods
codegen/valaccodebasemodule.vala | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 15a4aa6..0684436 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1766,6 +1766,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
void capture_parameter (Parameter param, CCodeStruct data, int block_id) {
generate_type_declaration (param.variable_type, cfile);
+ var m = param.parent_symbol as Method;
+ bool coroutine = m != null && m.coroutine;
+
var param_type = param.variable_type.copy ();
if (!param.variable_type.value_owned) {
param_type.value_owned = !no_implicit_copy (param.variable_type);
@@ -1775,7 +1778,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// create copy if necessary as captured variables may need to be kept alive
param.captured = false;
var value = load_parameter (param);
- if (requires_copy (param_type) && !param.variable_type.value_owned) {
+ if (requires_copy (param_type) && !param.variable_type.value_owned && !coroutine) {
// directly access parameters in ref expressions
value = copy_value (value, param);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]