From 82ea416c344a2d701b2e2facabd609a1bb59edea Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 27 Jan 2014 22:19:26 +0900 Subject: [PATCH] get rid of redundant code in is_closed function --- src/codegen.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/codegen.c b/src/codegen.c index ce92b196..52fae0b4 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -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 {