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



commit 7be37315355ae4ece0615a4a99f0b21882b795e6
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 cb472e578..11f4d4ae7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2238,11 +2238,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]