diff options
author | Damien George <damien.p.george@gmail.com> | 2016-09-30 12:34:05 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-09-30 12:34:05 +1000 |
commit | 3dea8c9e926d0c1b1049ff9d5abeedfb001fc201 (patch) | |
tree | f99592adff2bf9563e214e0f985d83e3d1226a61 /py/emitcommon.c | |
parent | 6ab2c5e6cc6359c3419a9d8ee61b4e586864d048 (diff) | |
download | micropython-3dea8c9e926d0c1b1049ff9d5abeedfb001fc201.tar.gz micropython-3dea8c9e926d0c1b1049ff9d5abeedfb001fc201.zip |
py/scope: Use lookup-table to determine a scope's simple name.
Generates slightly smaller and more efficient code.
Diffstat (limited to 'py/emitcommon.c')
-rw-r--r-- | py/emitcommon.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/py/emitcommon.c b/py/emitcommon.c index 435188f366..2925f4cafe 100644 --- a/py/emitcommon.c +++ b/py/emitcommon.c @@ -50,12 +50,12 @@ void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) { bool added; id_info_t *id = scope_find_or_add_id(scope, qst, &added); if (added) { - if (scope->kind == SCOPE_MODULE || scope->kind == SCOPE_CLASS) { - id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; - } else { + if (SCOPE_IS_FUNC_LIKE(scope->kind)) { id->kind = ID_INFO_KIND_LOCAL; + } else { + id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; } - } else if (scope->kind >= SCOPE_FUNCTION && scope->kind <= SCOPE_GEN_EXPR && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + } else if (SCOPE_IS_FUNC_LIKE(scope->kind) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { // rebind as a local variable id->kind = ID_INFO_KIND_LOCAL; } |