]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Reduce calls of CodeContext.get()
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 11 Jun 2020 09:59:46 +0000 (11:59 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 11 Jun 2020 12:56:06 +0000 (14:56 +0200)
vala/valaarraytype.vala
vala/valadatatype.vala
vala/valapointertype.vala

index 9add1d0d4d03dd61bfd46300c983dd0672e27931..751933d71a1834085f30db0b490e9cf975446976 100644 (file)
@@ -205,13 +205,15 @@ public class Vala.ArrayType : ReferenceType {
        }
 
        public override bool compatible (DataType target_type) {
-               if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null) {
-                       if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol) && element_type.type_symbol == CodeContext.get ().root.scope.lookup ("string")) {
+               var context = CodeContext.get ();
+
+               if (context.profile == Profile.GOBJECT && target_type.type_symbol != null) {
+                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol) && element_type.type_symbol == context.root.scope.lookup ("string")) {
                                // allow implicit conversion from string[] to GValue
                                return true;
                        }
 
-                       if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.type_symbol)) {
+                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvariant_type.type_symbol)) {
                                // allow implicit conversion to GVariant
                                return true;
                        }
index 37d04a1edb970013df3c9c4e9de7789962153449..993c1432bf53df0c9e48f6d01a69763f0e5bbe35 100644 (file)
@@ -275,17 +275,19 @@ public abstract class Vala.DataType : CodeNode {
        }
 
        public virtual bool compatible (DataType target_type) {
-               if (CodeContext.get ().experimental_non_null && nullable && !target_type.nullable) {
+               var context = CodeContext.get ();
+
+               if (context.experimental_non_null && nullable && !target_type.nullable) {
                        return false;
                }
 
-               if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null) {
-                       if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol)) {
+               if (context.profile == Profile.GOBJECT && target_type.type_symbol != null) {
+                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol)) {
                                // allow implicit conversion to GValue
                                return true;
                        }
 
-                       if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.type_symbol)) {
+                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvariant_type.type_symbol)) {
                                // allow implicit conversion to GVariant
                                return true;
                        }
index 6efbad9bd8ed5f2441c560cb1560bfa6f4305f54..a8806230e2ee453b96cc4022966566120a39c09e 100644 (file)
@@ -83,7 +83,9 @@ public class Vala.PointerType : DataType {
                        return base_type.compatible (target_type);
                }
 
-               if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null && target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol)) {
+               var context = CodeContext.get ();
+
+               if (context.profile == Profile.GOBJECT && target_type.type_symbol != null && target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol)) {
                        // allow implicit conversion to GValue
                        return true;
                }