[vala] codegen: Drop unnecessary comma expressions in silent casts
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Drop unnecessary comma expressions in silent casts
- Date: Wed, 16 Feb 2011 07:06:43 +0000 (UTC)
commit 46020b1425ae4bc998d6563f3852cf2176727335
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Feb 15 15:36:20 2011 +0100
codegen: Drop unnecessary comma expressions in silent casts
Assume temporary variable owns value depending on the relative
expression.
codegen/valaccodebasemodule.vala | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0052ece..08bddc0 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4707,21 +4707,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (context.profile == Profile.GOBJECT && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
if (expr.is_silent_cast) {
- var ccomma = new CCodeCommaExpression ();
- var temp_decl = get_temp_variable (expr.inner.value_type, true, expr, false);
-
+ var temp_decl = get_temp_variable (expr.inner.value_type, expr.inner.value_type.value_owned, expr, false);
emit_temp_var (temp_decl);
-
var ctemp = get_variable_cexpression (temp_decl.name);
- var cinit = new CCodeAssignment (ctemp, get_cvalue (expr.inner));
+
+ ccode.add_assignment (ctemp, get_cvalue (expr.inner));
var ccheck = create_type_check (ctemp, expr.type_reference);
var ccast = new CCodeCastExpression (ctemp, expr.type_reference.get_cname ());
var cnull = new CCodeConstant ("NULL");
-
- ccomma.append_expression (cinit);
- ccomma.append_expression (new CCodeConditionalExpression (ccheck, ccast, cnull));
- set_cvalue (expr, ccomma);
+ set_cvalue (expr, new CCodeConditionalExpression (ccheck, ccast, cnull));
} else {
set_cvalue (expr, generate_instance_cast (get_cvalue (expr.inner), expr.type_reference.data_type));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]