diff options
| author | Damien George <damien.p.george@gmail.com> | 2018-10-27 22:41:21 +1100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2018-10-28 00:38:18 +1100 |
| commit | e328a5d4693f9e4a03b296e7a9a7af6660d99515 (patch) | |
| tree | 178e4fbab5adbd14fb3c03e9754f044699626fc8 /py/scope.h | |
| parent | ba92c798414d5dcf76ac7bfd153884873cceca08 (diff) | |
py/scope: Optimise scope_find_or_add_id to not need "added" arg.
Taking the address of a local variable is mildly expensive, in code size
and stack usage. So optimise scope_find_or_add_id() to not need to take a
pointer to the "added" variable, and instead take the kind to use for newly
added identifiers.
Diffstat (limited to 'py/scope.h')
| -rw-r--r-- | py/scope.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/scope.h b/py/scope.h index d51bb90bb..ba07c3949 100644 --- a/py/scope.h +++ b/py/scope.h @@ -30,6 +30,7 @@ #include "py/emitglue.h" enum { + ID_INFO_KIND_UNDECIDED, ID_INFO_KIND_GLOBAL_IMPLICIT, ID_INFO_KIND_GLOBAL_EXPLICIT, ID_INFO_KIND_LOCAL, // in a function f, written and only referenced by f @@ -90,7 +91,7 @@ typedef struct _scope_t { scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, scope_kind_t kind); id_info_t *scope_find(scope_t *scope, qstr qstr); id_info_t *scope_find_global(scope_t *scope, qstr qstr); void scope_check_to_close_over(scope_t *scope, id_info_t *id); |
