summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-12-05 14:08:36 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2019-12-05 14:08:36 +0100
commit7551bbbe8ee6dc9cec3f17436a773f80e5bc2125 (patch)
treeb367f043c59561f5f4852797d622f7c6703768c7
parent8ee44db879457846294ab80ba17280b228e7e2e9 (diff)
downloadvala-7551bbbe8ee6dc9cec3f17436a773f80e5bc2125.tar.gz
codegen: Remove unreachable code in TypeRegisterFunction.init_from_type()
Not used since 79b1a3e39a3d2bac9fbe40c99336b3b89e374571
-rw-r--r--codegen/valatyperegisterfunction.vala54
1 files changed, 15 insertions, 39 deletions
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index 394295f9b..23ab2321a 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -35,7 +35,6 @@ public abstract class Vala.TypeRegisterFunction {
*/
public void init_from_type (CodeContext context, bool plugin, bool declaration_only) {
var type_symbol = get_type_declaration ();
- bool use_thread_safe = !plugin;
bool fundamental = false;
unowned Class? cl = type_symbol as Class;
@@ -47,20 +46,15 @@ public abstract class Vala.TypeRegisterFunction {
var type_block = new CCodeBlock ();
CCodeDeclaration cdecl;
- if (use_thread_safe) {
+ if (!plugin) {
cdecl = new CCodeDeclaration ("gsize");
cdecl.add_declarator (new CCodeVariableDeclarator (type_id_name + "__volatile", new CCodeConstant ("0")));
+ cdecl.modifiers = CCodeModifiers.STATIC | CCodeModifiers.VOLATILE;
+ type_block.add_statement (cdecl);
} else {
cdecl = new CCodeDeclaration ("GType");
cdecl.add_declarator (new CCodeVariableDeclarator (type_id_name, new CCodeConstant ("0")));
- }
- cdecl.modifiers = CCodeModifiers.STATIC;
- if (use_thread_safe) {
- cdecl.modifiers |= CCodeModifiers.VOLATILE;
- }
- if (!plugin) {
- type_block.add_statement (cdecl);
- } else {
+ cdecl.modifiers = CCodeModifiers.STATIC;
source_declaration_fragment.append (cdecl);
}
@@ -200,7 +194,7 @@ public abstract class Vala.TypeRegisterFunction {
reg_call.add_argument (new CCodeConstant (get_type_flags ()));
}
- if (use_thread_safe && !plugin) {
+ if (!plugin) {
var temp_decl = new CCodeDeclaration ("GType");
temp_decl.add_declarator (new CCodeVariableDeclarator (type_id_name, reg_call));
type_init.add_statement (temp_decl);
@@ -233,38 +227,20 @@ public abstract class Vala.TypeRegisterFunction {
}
if (!plugin) {
- CCodeExpression condition; // the condition that guards the type initialisation
- if (use_thread_safe) {
- var enter = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_enter"));
- enter.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name + "__volatile")));
- condition = enter;
-
- var leave = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_leave"));
- leave.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name + "__volatile")));
- leave.add_argument (new CCodeIdentifier (type_id_name));
- type_init.add_statement (new CCodeExpressionStatement (leave));
- } else {
- var id = new CCodeIdentifier (type_id_name);
- var zero = new CCodeConstant ("0");
- condition = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, id, zero);
- }
+ // the condition that guards the type initialisation
+ var enter = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_enter"));
+ enter.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name + "__volatile")));
- CCodeExpression cond;
- if (use_thread_safe) {
- cond = condition;
- } else {
- cond = new CCodeFunctionCall (new CCodeIdentifier ("G_UNLIKELY"));
- ((CCodeFunctionCall) cond).add_argument (condition);
- }
- var cif = new CCodeIfStatement (cond, type_init);
- type_block.add_statement (cif);
- } else {
- type_block = type_init;
- }
+ var leave = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_leave"));
+ leave.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name + "__volatile")));
+ leave.add_argument (new CCodeIdentifier (type_id_name));
+ type_init.add_statement (new CCodeExpressionStatement (leave));
- if (use_thread_safe) {
+ var cif = new CCodeIfStatement (enter, type_init);
+ type_block.add_statement (cif);
type_block.add_statement (new CCodeReturnStatement (new CCodeIdentifier (type_id_name + "__volatile")));
} else {
+ type_block = type_init;
type_block.add_statement (new CCodeReturnStatement (new CCodeIdentifier (type_id_name)));
}