summaryrefslogtreecommitdiff
path: root/py/emitcommon.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-09-30 13:53:00 +1000
committerDamien George <damien.p.george@gmail.com>2016-09-30 13:53:00 +1000
commit0d10517a45fc90e7da9fc527ccfe51ab10205548 (patch)
treebef561084c21afdf93a6eede74371df8518bfbb5 /py/emitcommon.c
parentd5495966cea38f452646b2f171859f66bebcf05e (diff)
py/scope: Factor common code to find locals and close over them.
Saves 50-100 bytes of code.
Diffstat (limited to 'py/emitcommon.c')
-rw-r--r--py/emitcommon.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/py/emitcommon.c b/py/emitcommon.c
index 2925f4caf..e914431d3 100644
--- a/py/emitcommon.c
+++ b/py/emitcommon.c
@@ -35,13 +35,7 @@ void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) {
bool added;
id_info_t *id = scope_find_or_add_id(scope, qst, &added);
if (added) {
- id_info_t *id2 = scope_find_local_in_parent(scope, qst);
- if (id2 != NULL && (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE)) {
- id->kind = ID_INFO_KIND_FREE;
- scope_close_over_in_parents(scope, qst);
- } else {
- id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
- }
+ scope_find_local_and_close_over(scope, id, qst);
}
}