From 23ba58bbf574d029d5b18e57c40d4257b37dfd7a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 13 May 2020 10:05:48 -0500 Subject: [PATCH] Gamepad & GamepadShift: Initially allocate as long-lived This makes less heap churn and decreases code size a tiny bit --- shared-bindings/gamepad/GamePad.c | 3 +-- shared-bindings/gamepadshift/GamePadShift.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 88f072f3eb..d6f91c1c08 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -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(); } diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index 76f054aae9..9586e01ed9 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -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(); }