get rid of redundant code in is_closed function

This commit is contained in:
Yuichi Nishiwaki 2014-01-27 22:19:26 +09:00
parent 2f8b016d86
commit 82ea416c34
1 changed files with 3 additions and 9 deletions

View File

@ -754,15 +754,9 @@ pop_resolver_scope(resolver_state *state)
}
static bool
is_closed(resolver_state *state, int depth, pic_sym sym)
is_closed(resolver_state *state, pic_sym sym)
{
resolver_scope *scope = state->scope;
while (depth-- > 0) {
scope = scope->up;
}
return xh_get(scope->cvs, pic_symbol_name(state->pic, sym)) != NULL;
return xh_get(state->scope->cvs, pic_symbol_name(state->pic, sym)) != NULL;
}
static pic_value
@ -851,7 +845,7 @@ resolve_reference_node(resolver_state *state, pic_value obj)
if (depth == scope->depth) {
return resolve_gref(state, sym);
}
else if (depth == 0 && is_closed(state, depth, sym)) {
else if (depth == 0 && is_closed(state, sym)) {
return resolve_lref(state, sym);
}
else {