From: Rico Tzschichholz Date: Mon, 23 Apr 2018 15:09:00 +0000 (+0200) Subject: codegen: Avoid ref/unref of AttributeCache when calling get_ccode_attribute() X-Git-Tag: 0.41.90~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b7f6259d5cb491562c17c974d98fb12152e381f;p=thirdparty%2Fvala.git codegen: Avoid ref/unref of AttributeCache when calling get_ccode_attribute() --- diff --git a/codegen/valaccode.vala b/codegen/valaccode.vala index 0305f2ec5..82b4699e7 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; }