Browse Source

py/objdeque: Use m_new0 when allocating items to avoid need to clear.

Saves a few bytes of code space, and is more efficient because with
MICROPY_GC_CONSERVATIVE_CLEAR enabled by default all memory is already
cleared when allocated.
pull/3629/head
Damien George 7 years ago
parent
commit
6e675c1baa
  1. 3
      py/objdeque.c

3
py/objdeque.c

@ -60,8 +60,7 @@ STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t
o->base.type = type;
o->alloc = maxlen + 1;
o->i_get = o->i_put = 0;
o->items = m_new(mp_obj_t, o->alloc);
mp_seq_clear(o->items, 0, o->alloc, sizeof(*o->items));
o->items = m_new0(mp_obj_t, o->alloc);
if (n_args > 2) {
o->flags = mp_obj_get_int(args[2]);

Loading…
Cancel
Save