diff options
author | Damien George <damien.p.george@gmail.com> | 2017-01-17 15:27:37 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-02-16 18:38:06 +1100 |
commit | 088740ecc40476fd0796a3ef6a68ee7c677eae64 (patch) | |
tree | 97284e7a795fbf6e0a196bbe56234d7fff5fc74b /py/compile.c | |
parent | 6e769da0da2ae24cbdab50c57f0d088e137146e3 (diff) |
py: Optimise storage of iterator so it takes only 4 slots on Py stack.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/py/compile.c b/py/compile.c index 4fde278d0..5ea7bb4b2 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2887,7 +2887,7 @@ STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pn EMIT(yield_value); EMIT(pop_top); } else { - EMIT_ARG(store_comp, comp->scope_cur->kind, 5 * for_depth + 6); + EMIT_ARG(store_comp, comp->scope_cur->kind, 4 * for_depth + 5); } } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn_iter, PN_comp_if)) { // if condition @@ -3070,13 +3070,13 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { #endif } - // dummy 4 objects - EMIT(load_null); + // There are 4 slots on the stack for the iterator, and the first one is + // NULL to indicate that the second one points to the iterator object. EMIT(load_null); + compile_load_id(comp, qstr_arg); EMIT(load_null); EMIT(load_null); - compile_load_id(comp, qstr_arg); compile_scope_comp_iter(comp, pns_comp_for, pns->nodes[0], 0); if (scope->kind == SCOPE_GEN_EXPR) { |