py: Add n_state to mp_code_state_t struct.

This value is used often enough that it is better to cache it instead of
decode it each time.
This commit is contained in:
Damien George
2019-09-24 15:57:08 +10:00
parent 4c5e1a0368
commit 81d04a0200
5 changed files with 12 additions and 5 deletions

View File

@@ -62,6 +62,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
o->globals = self_fun->globals;
o->code_state.fun_bc = self_fun;
o->code_state.ip = 0;
o->code_state.n_state = n_state;
mp_setup_code_state(&o->code_state, n_args, n_kw, args);
return MP_OBJ_FROM_PTR(o);
}
@@ -99,6 +100,7 @@ STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_k
o->globals = self_fun->globals;
o->code_state.fun_bc = self_fun;
o->code_state.ip = (const byte*)prelude_offset;
o->code_state.n_state = n_state;
mp_setup_code_state(&o->code_state, n_args, n_kw, args);
// Indicate we are a native function, which doesn't use this variable