summaryrefslogtreecommitdiff
path: root/ccode/valaccodeblock.vala
diff options
context:
space:
mode:
authorJuerg Billeter <j@bitron.ch>2008-04-07 14:26:05 +0000
committerJürg Billeter <juergbi@src.gnome.org>2008-04-07 14:26:05 +0000
commit5a55118c6c7b7983944e100c27eab8ad1450f9d8 (patch)
tree98999b392419ddbecf3a342dd8b16611aa9cc7d6 /ccode/valaccodeblock.vala
parent3c46988e0dbca6c072633de40bc3cd2cd918f2c1 (diff)
downloadvala-5a55118c6c7b7983944e100c27eab8ad1450f9d8.tar.gz
two small optimizations, patch by Jaap A. Haitsma, fixes bug 526243
2008-04-07 Juerg Billeter <j@bitron.ch> * ccode/valaccodeblock.vala, ccode/valaccodeincludedirective.vala: two small optimizations, patch by Jaap A. Haitsma, fixes bug 526243 svn path=/trunk/; revision=1173
Diffstat (limited to 'ccode/valaccodeblock.vala')
-rw-r--r--ccode/valaccodeblock.vala15
1 files changed, 7 insertions, 8 deletions
diff --git a/ccode/valaccodeblock.vala b/ccode/valaccodeblock.vala
index 8ac4d7433..2aa5bd136 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;
}
}