]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: simplify loop in var_block_close()
[ocean] / csrc / oceani.mdc
index 4bd3959f5147ac5bdcab4f1d46760f5cbc60fcec..0772bcff3000e8816f863bd63a201856c885941a 100644 (file)
@@ -1147,9 +1147,17 @@ all pending-scope variables become conditionally scoped.
 
                scope_pop(c);
                for (vp = &c->in_scope;
-                    v = *vp, v && v->min_depth > c->scope_depth;
-                    ) {
-                       if (v->name->var == v) switch (ct) {
+                    (v = *vp) && v->min_depth > c->scope_depth;
+                    (v->scope == OutScope || v->name->var != v)
+                    ? (*vp =  v->in_scope, 0)
+                    : ( vp = &v->in_scope, 0)) {
+                       if (v->name->var != v) {
+                               /* This is still in scope, but we haven't just
+                                * closed the scope.
+                                */
+                               continue;
+                       }
+                       switch (ct) {
                        case CloseElse:
                        case CloseParallel: /* handle PendingScope */
                                switch(v->scope) {
@@ -1210,10 +1218,6 @@ all pending-scope variables become conditionally scoped.
                                }
                                break;
                        }
-                       if (v->scope == OutScope || v->name->var != v)
-                               *vp = v->in_scope;
-                       else
-                               vp = &v->in_scope;
                }
        }