Gamepad & GamepadShift: Initially allocate as long-lived

This makes less heap churn and decreases code size a tiny bit
This commit is contained in:
Jeff Epler 2020-05-13 10:05:48 -05:00
parent fbf052bb27
commit 23ba58bbf5
2 changed files with 2 additions and 4 deletions

View File

@ -106,9 +106,8 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton);
if (!gamepad_singleton ||
!MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton), &gamepad_type)) {
gamepad_singleton = m_new_obj(gamepad_obj_t);
gamepad_singleton = m_new_ll_obj(gamepad_obj_t);
gamepad_singleton->base.type = &gamepad_type;
gamepad_singleton = gc_make_long_lived(gamepad_singleton);
if (!MP_STATE_VM(gamepad_singleton)) {
supervisor_enable_tick();
}

View File

@ -73,9 +73,8 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args,
if (!gamepad_singleton ||
!MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton),
&gamepadshift_type)) {
gamepad_singleton = m_new_obj(gamepadshift_obj_t);
gamepad_singleton = m_new_ll_obj(gamepadshift_obj_t);
gamepad_singleton->base.type = &gamepadshift_type;
gamepad_singleton = gc_make_long_lived(gamepad_singleton);
if (!MP_STATE_VM(gamepad_singleton)) {
supervisor_enable_tick();
}