[vala/0.48] vala: Reduce calls of CodeContext.get()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Reduce calls of CodeContext.get()
- Date: Mon, 22 Jun 2020 07:02:37 +0000 (UTC)
commit 11513aefe71e721ee93c9ac8d50d322b533957fb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Jun 11 11:59:46 2020 +0200
vala: Reduce calls of CodeContext.get()
vala/valaarraytype.vala | 8 +++++---
vala/valadatatype.vala | 10 ++++++----
vala/valapointertype.vala | 4 +++-
3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 9add1d0d4..751933d71 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -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;
}
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 37d04a1ed..993c1432b 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -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;
}
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 6efbad9bd..a8806230e 100644
--- a/vala/valapointertype.vala
+++ b/vala/valapointertype.vala
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]