]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Cache type_symbol in get_param_spec()
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 2 Jul 2020 17:50:48 +0000 (19:50 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 2 Jul 2020 17:50:48 +0000 (19:50 +0200)
codegen/valagtypemodule.vala

index 4757b0165d75ca3ec1d17ab280346c50d492571d..3aba4b96d9928e35d0b8054a901c6373fe9febcc 100644 (file)
@@ -1832,20 +1832,20 @@ public class Vala.GTypeModule : GErrorModule {
                cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick)));
                cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
 
-
-               if (prop.property_type.type_symbol is Class || prop.property_type.type_symbol is Interface) {
-                       string param_spec_name = get_ccode_param_spec_function (prop.property_type.type_symbol);
+               unowned TypeSymbol? type_symbol = prop.property_type.type_symbol;
+               if (type_symbol is Class || type_symbol is Interface) {
+                       string param_spec_name = get_ccode_param_spec_function (type_symbol);
                        cspec.call = new CCodeIdentifier (param_spec_name);
                        if (param_spec_name == "g_param_spec_string") {
                                cspec.add_argument (new CCodeConstant ("NULL"));
                        } else if (param_spec_name == "g_param_spec_variant") {
                                cspec.add_argument (new CCodeConstant ("G_VARIANT_TYPE_ANY"));
                                cspec.add_argument (new CCodeConstant ("NULL"));
-                       } else if (get_ccode_type_id (prop.property_type.type_symbol) != "G_TYPE_POINTER") {
-                               cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (prop.property_type.type_symbol)));
+                       } else if (get_ccode_type_id (type_symbol) != "G_TYPE_POINTER") {
+                               cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (type_symbol)));
                        }
-               } else if (prop.property_type.type_symbol is Enum) {
-                       unowned Enum e = (Enum) prop.property_type.type_symbol;
+               } else if (type_symbol is Enum) {
+                       unowned Enum e = (Enum) type_symbol;
                        if (get_ccode_has_type_id (e)) {
                                if (e.is_flags) {
                                        cspec.call = new CCodeIdentifier ("g_param_spec_flags");
@@ -1868,10 +1868,10 @@ public class Vala.GTypeModule : GErrorModule {
                        if (prop.initializer != null) {
                                cspec.add_argument ((CCodeExpression) get_ccodenode (prop.initializer));
                        } else {
-                               cspec.add_argument (new CCodeConstant (get_ccode_default_value (prop.property_type.type_symbol)));
+                               cspec.add_argument (new CCodeConstant (get_ccode_default_value (type_symbol)));
                        }
-               } else if (prop.property_type.type_symbol is Struct) {
-                       unowned Struct st = (Struct) prop.property_type.type_symbol;
+               } else if (type_symbol is Struct) {
+                       unowned Struct st = (Struct) type_symbol;
                        var type_id = get_ccode_type_id (st);
                        if (type_id == "G_TYPE_INT") {
                                cspec.call = new CCodeIdentifier ("g_param_spec_int");