Skip to content

Commit

Permalink
py/obj: Add MP_NOINLINE to mp_obj_malloc_helper.
Browse files Browse the repository at this point in the history
As the comment in py/obj.h says:

> Implementing this as a call rather than inline saves 8 bytes per usage.

So in order to get this savings, we need to tell the compiler to never
inline the function.

Signed-off-by: David Lechner <[email protected]>
  • Loading branch information
dlech committed Mar 17, 2023
1 parent 05bb260 commit fa8ebb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion py/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "py/stream.h" // for mp_obj_print

// Allocates an object and also sets type, for mp_obj_malloc{,_var} macros.
void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type) {
MP_NOINLINE void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type) {
mp_obj_base_t *base = (mp_obj_base_t *)m_malloc(num_bytes);
base->type = type;
return base;
Expand Down

0 comments on commit fa8ebb1

Please sign in to comment.