From 5a55118c6c7b7983944e100c27eab8ad1450f9d8 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Mon, 7 Apr 2008 14:26:05 +0000 Subject: [PATCH] two small optimizations, patch by Jaap A. Haitsma, fixes bug 526243 2008-04-07 Juerg Billeter * ccode/valaccodeblock.vala, ccode/valaccodeincludedirective.vala: two small optimizations, patch by Jaap A. Haitsma, fixes bug 526243 svn path=/trunk/; revision=1173 --- ChangeLog | 5 +++++ ccode/valaccodeblock.vala | 15 +++++++-------- ccode/valaccodeincludedirective.vala | 8 +++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad16e8b..85d22d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-04-07 Jürg Billeter + * ccode/valaccodeblock.vala, ccode/valaccodeincludedirective.vala: + two small optimizations, patch by Jaap A. Haitsma, fixes bug 526243 + +2008-04-07 Jürg Billeter + * vala/valasemanticanalyzer.vala: fix spurious error when overriding abstract method in derived abstract class, fixes bug 523263 diff --git a/ccode/valaccodeblock.vala b/ccode/valaccodeblock.vala index 8ac4d74..2aa5bd1 100644 --- a/ccode/valaccodeblock.vala +++ b/ccode/valaccodeblock.vala @@ -51,20 +51,19 @@ public class Vala.CCodeBlock : CCodeStatement { } public override void write (CCodeWriter! writer) { + // the last reachable statement + CCodeNode last_statement = null; + writer.write_begin_block (); foreach (CCodeNode statement in statements) { statement.write_declaration (writer); - } - // compute last reachable statement - CCodeNode last_statement = null; - foreach (CCodeNode statement in statements) { - if (statement is CCodeReturnStatement || statement is CCodeGotoStatement - || statement is CCodeContinueStatement || statement is CCodeBreakStatement) { - last_statement = statement; - } + // determine last reachable statement if (statement is CCodeLabel) { last_statement = null; + } else if (statement is CCodeReturnStatement || statement is CCodeGotoStatement + || statement is CCodeContinueStatement || statement is CCodeBreakStatement) { + last_statement = statement; } } diff --git a/ccode/valaccodeincludedirective.vala b/ccode/valaccodeincludedirective.vala index 18cf052..b7a6311 100644 --- a/ccode/valaccodeincludedirective.vala +++ b/ccode/valaccodeincludedirective.vala @@ -47,13 +47,11 @@ public class Vala.CCodeIncludeDirective : CCodeNode { writer.write_string ("#include "); if (local) { writer.write_string ("\""); - } else { - writer.write_string ("<"); - } - writer.write_string (filename); - if (local) { + writer.write_string (filename); writer.write_string ("\""); } else { + writer.write_string ("<"); + writer.write_string (filename); writer.write_string (">"); } writer.write_newline (); -- 2.7.4