[vala/staging] codegen: Avoid ref/unref of AttributeCache when calling	get_ccode_attribute()
- From: Rico Tzschichholz <ricotz src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [vala/staging] codegen: Avoid ref/unref of AttributeCache when calling	get_ccode_attribute()
 
- Date: Mon, 23 Apr 2018 17:20:13 +0000 (UTC)
 
commit 4b7f6259d5cb491562c17c974d98fb12152e381f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Apr 23 17:09:00 2018 +0200
    codegen: Avoid ref/unref of AttributeCache when calling get_ccode_attribute()
 codegen/valaccode.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccode.vala b/codegen/valaccode.vala
index 0305f2e..82b4699 100644
--- a/codegen/valaccode.vala
+++ b/codegen/valaccode.vala
@@ -23,15 +23,16 @@
 namespace Vala {
        static int? ccode_attribute_cache_index = null;
 
-       static CCodeAttribute get_ccode_attribute (CodeNode node) {
+       static unowned CCodeAttribute get_ccode_attribute (CodeNode node) {
                if (ccode_attribute_cache_index == null) {
                        ccode_attribute_cache_index = CodeNode.get_attribute_cache_index ();
                }
 
-               var attr = node.get_attribute_cache (ccode_attribute_cache_index);
+               unowned AttributeCache? attr = node.get_attribute_cache (ccode_attribute_cache_index);
                if (attr == null) {
-                       attr = new CCodeAttribute (node);
-                       node.set_attribute_cache (ccode_attribute_cache_index, attr);
+                       var new_attr = new CCodeAttribute (node);
+                       node.set_attribute_cache (ccode_attribute_cache_index, new_attr);
+                       attr = new_attr;
                }
                return (CCodeAttribute) attr;
        }
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]