[vala/0.52] codegen: Use if-clause for is_in_destructor() condition to be more clear



commit 39bce1525eda0c3cdedef5e783fef7d177d65030
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 18 21:02:21 2021 +0200

    codegen: Use if-clause for is_in_destructor() condition to be more clear

 codegen/valaccodebasemodule.vala | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index a76ae8fcb..714a3c289 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2243,11 +2243,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                unowned DataType? this_type = get_this_type ();
                                if (this_type != null && (!in_creation_method_with_chainup || 
current_method.body != b)) {
-                                       var ref_call = new CCodeFunctionCall (get_dup_func_expression 
(this_type, b.source_reference));
-                                       ref_call.add_argument (get_this_cexpression ());
-
-                                       // never increase reference count for self in finalizers to avoid 
infinite recursion on following unref
-                                       var instance = (is_in_destructor () ? (CCodeExpression) new 
CCodeIdentifier ("self") : (CCodeExpression) ref_call);
+                                       CCodeExpression instance;
+                                       if (is_in_destructor ()) {
+                                               // never increase reference count for self in finalizers to 
avoid infinite recursion on following unref
+                                               instance = new CCodeIdentifier ("self");
+                                       } else {
+                                               var ref_call = new CCodeFunctionCall (get_dup_func_expression 
(this_type, b.source_reference));
+                                               ref_call.add_argument (get_this_cexpression ());
+                                               instance = ref_call;
+                                       }
 
                                        ccode.add_assignment (new CCodeMemberAccess.pointer 
(get_variable_cexpression ("_data%d_".printf (block_id)), "self"), instance);
                                }


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